# Thread: compute pi

1. ## compute pi

Anybody have a clue how to compute the nth digit of pi?

2. I bet Google knows! How about you go ask?

Quzah.

3. >Anybody have a clue how to compute the nth digit of pi?
Yes.

-Prelude

4. Originally posted by quzah
I bet Google knows! How about you go ask?

Quzah.
Never would of thought of that.

>yes

If yes, then please give me some insight. I have done some research into this. Where I stand now is this, to compute pi traditionally (arcsin, etc), I think it would be impossible for me to do past 12 decimal places. Atleast on my machine, because the mantissa is only 56 bits long. I am thinking there are some nifty tricks an expreienced programmer might know to exploit your FPU.

The way I am doing it now is using a fairly new algorithim that amazingly computes any nth digit of pi. The only catch is that the calculation can only be done in hex. Meaning it is impossible to get the answer back to decimal. While this is good, it is not what I want. So I am hoping someone has done this before and can lend some advice....

5. Never would of thought of that.
Most people don't.

Quzah.

6. >If yes, then please give me some insight.
I would, but you can find it with ease simply by using a search engine. So far I haven't computed PI farther than about 50,000 digits without signifigant slowdown, you might want to be more specific as to what you want your minimum limit to be.

-Prelude

7. >So far I haven't computed PI farther than about 50,000 digits without signifigant slowdown.
Prelude, don't you have anything better to do! [/sarcasm]

8. >Prelude, don't you have anything better to do!
Of course, but better isn't always more fun.

-Prelude

9. Wait a tick...

> The only catch is that the calculation can only be done in hex. Meaning it is impossible to get the answer back to decimal.

Why is it impossible to get from hex to decimal?

10. try with Smalltalk

11. Originally posted by Govtcheez
Wait a tick...

> The only catch is that the calculation can only be done in hex. Meaning it is impossible to get the answer back to decimal.

Why is it impossible to get from hex to decimal?
i guess the author of that quote screwed up somewhere.

12. Actually the author didn't screw up. The algorythm finds the Nth HEX digit of PI, not the Nth DECIMAL digit of PI. Big difference.

Quzah.

13. Here you go, from the Obfuscated C Contest

Code:
```/*
* Program to compute an approximation of pi
* by Brian Westley, 1988
* (requires pcc macro concatenation; try gcc -traditional-cpp)
*/

#define _ -F<00||--F-OO--;
int F=00,OO=00;
main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}```
Note that this program works by computing its own area. For more digits, write a bigger program.

Hehe, got to love having the New Hackers Dictionary sitting on my desk, always comes in handy.

----------------------
Proud to be a gun carrying, freedom loving, libertarian.
Don't Listen to Right Wing Propaganda. Legalize it NOW!

Popular pages Recent additions