Anybody have a clue how to compute the nth digit of pi?
Anybody have a clue how to compute the nth digit of pi?
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition
I bet Google knows! How about you go ask?
Quzah.
Hope is the first step on the road to disappointment.
>Anybody have a clue how to compute the nth digit of pi?
Yes.
-Prelude
My best code is written with the delete key.
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....
'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition
Most people don't.Never would of thought of that.
Quzah.
Hope is the first step on the road to disappointment.
>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
My best code is written with the delete key.
>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]
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
>Prelude, don't you have anything better to do!
Of course, but better isn't always more fun.
-Prelude
My best code is written with the delete key.
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?
-Govtcheez
[email protected]
try with Smalltalk
i guess the author of that quote screwed up somewhere.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?
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.
Last edited by quzah; 08-01-2002 at 06:43 PM.
Hope is the first step on the road to disappointment.
Here you go, from the Obfuscated C Contest
Note that this program works by computing its own area. For more digits, write a bigger program.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() { _-_-_-_ _-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_-_-_-_-_ _-_-_-_-_-_-_-_ _-_-_-_ }
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!