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

RE: Re: [FWP] algorithm to calculate pi



This is silimar to my first try on Math::BigFloat, but it actually
gave wrong output:

3.141592653589789906415624616868420198429944033964538859872897174200379404510127908381563911160127313025842000052228971838803850

you may find the correct one(which is also the C code produced)here:

http://www.joyofpi.com/pi.htm
3.
1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 5058223172 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 4428810975


>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




------------------------------------------------------------
Email account furnished courtesy of AntiOnline - http://www.AntiOnline.com
AntiOnline - The Internet's Information Security Super Center!


******************************************************
Make FREE long distance phone calls online!	
Click here to use PhoneFREE.com today!
http://adserv.internetfuel.com/cgi-bin/newredirect.cgi?AD=EMAIL-phonefree
******************************************************

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