[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] algorithm to calculate pi



                       On Sun, 25 Jun 2000 20:15:21 PDT,
                              "Perl lover" wrote:

:But if you read the C program.. the precision is the whole point
:here. I tried to play with Math::BigFloat.. seems can't
:come up with something easy..

How about this:

   use Math::BigFloat;
   my $p = new Math::BigFloat "0";
   for(0..280){
      my $i=$_*8;
      $p += (16**-$_)*(4/($i+1)-2/($i+4)-1/($i+5)-1/($i+6));
   }
   print $p;

Michael


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe