Re: Help converting C to PHP

From: Date: Fri, 22 Sep 2006 02:43:13 +0000
Subject: Re: Help converting C to PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-242057@lists.php.net to get a copy of this message
pi() does not give me enough decimal places, I need the first 1000. Curt Zirzow wrote:
On 9/21/06, Tom Atkinson <nibbler@coppermine-gallery.net> wrote:
Hello, I am attempting to convert this code for generating the digits of pi from the original C (below) to PHP. long k=4e3,p,a[337],q,t=1e3; main(j){for(;a[j=q=0]+=2,--k;) for(p=1+2*k;j<337;q=a[j]*k+q%p*t,a[j++]=q/p) k!=j>2?:printf("%.3d",a[j-2]%t+q/p/t);}
wow this is rather bad. it would probably be better to write this in asm, it would be easier to read than the way it is in C.
I converted this to a more readable form:
what about using: php.net/pi note the precision description. or are we talking about a different pi. Curt.


« previous php.general (#242057) next »