How many digits of PI to use?
well, because there are no dumb questions, i''ll ask this one:
how many digits of PI should i put in my pi-define?
are there speed / precision tradeoffs?
(i am using floats throughout my app, no doubles anywhere)
here are the first about 1000 digits of PI, just for your amazement
if you are interested in the first 1.000.000 digits, visit this absolutely interesting site: http://www.cs.williams.edu/~bailey/pi.html
rid
3.1415926535897932384626433832795028841971693993751
05820974944592307816406286208998628034825342117067
98214808651328230664709384460955058223172535940812
84811174502841027019385211055596446229489549303819
64428810975665933446128475648233786783165271201909
14564856692346034861045432664821339360726024914127
37245870066063155881748815209209628292540917153643
67892590360011330530548820466521384146951941511609
43305727036575959195309218611738193261179310511854
80744623799627495673518857527248912279381830119491
29833673362440656643086021394946395224737190702179
86094370277053921717629317675238467481846766940513
20005681271452635608277857713427577896091736371787
21468440901224953430146549585371050792279689258923
54201995611212902196086403441815981362977477130996
05187072113499999983729780499510597317328160963185
95024459455346908302642522308253344685035261931188
There are no tradeoffs such as speed lost. I copied and pasted the first 1,000,000 digits of PI in my define statement, and it works very accurately.
Hope this helps.
-------------------------------
I'll screw up whoever screws around with the gamedev forum!
..-=gLaDiAtOr=-..
Hope this helps.
-------------------------------
I'll screw up whoever screws around with the gamedev forum!
..-=gLaDiAtOr=-..
i believe floats have a certain number of dp (decimal places), somethign like 5, so anything in excess of that is discarded anyway
quote: Original post by Gladiator
I copied and pasted the first 1,000,000 digits of PI in my define statement, and it works very accurately.
You''re kidding, right? I hope?
Anyway, just use enough digits to get the maximum precision that the variable type can hold. Floats don''t have a fixed number of decimal places they can represent, exactly -- it''s more complicated than that -- but I''d say that anything more than six digits would be as accurate as you''d ever need. And anything more than twelve or so is just a waste of space.
-Ironblayde
Aeon Software
The following sentence is true.
The preceding sentence is false.
"Your superior intellect is no match for our puny weapons!"
quote: Original post by Ironblayde
And anything more than twelve or so is just a waste of space.
Not "just a waste of space", it''s also cool! I use about ten digits. It shouldn''t really matter as long as you don''t use below four or so.
-Jussi
(quote space for sale (for free)
____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux
Well, if you have PI to 30 decimal places, that is accurate enough to calculate the radius of the universe to the precision of one hydrogen atom. So I don''t think you need any more accuracy than that.
However, this isn''t directly related to DirectX/OpenGL or any other API, it is a more general thing, so I''m putting it in General & Game Programming.
Please state the nature of the debugging emergency.
However, this isn''t directly related to DirectX/OpenGL or any other API, it is a more general thing, so I''m putting it in General & Game Programming.
Please state the nature of the debugging emergency.
You could always generate PI with the Gregory series, then you can go as accurate as you like
-- Kazan - Fire Mountain Games --
Edited by - Kazan on October 20, 2000 9:42:49 AM
#define ACCURACY 10000000000.0 // The higher the num the higher the accuracylong double pi = 1.0;for( long double i = 3.0; i < ACCURACY; i += 4.0 ){ pi -= 1.0 / i; pi += 1.0 / (i + 2.0);}pi *= 4.0;
-- Kazan - Fire Mountain Games --
Edited by - Kazan on October 20, 2000 9:42:49 AM
When I hit the PI button on my calculator I get 3.141592654
This number has never failed me.
One way you can check to see how much the compiler truncates the number is make a program, store the huge long value of pi that you have in a float variable, then print it out and see what you get. It should deffinetly be alot shorter. Then, that''s the number to use.
This number has never failed me.
One way you can check to see how much the compiler truncates the number is make a program, store the huge long value of pi that you have in a float variable, then print it out and see what you get. It should deffinetly be alot shorter. Then, that''s the number to use.
[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement