Re: Help converting C to PHP
| From: | Richard Lynch | Date: | Fri, 22 Sep 2006 22:57:52 +0000 |
| Subject: | Re: Help converting C to PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242093@lists.php.net to get a copy of this message | ||
On Thu, September 21, 2006 9:32 pm, 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.
We're probably talking about that silly contest started the other day
to calculate pi to 1000 digits...
:-)
My best guess is that the C code is relying on type-casting to hack
something somewhere.
--
Like Music?
http://l-i-e.com/artists.htm