Perl: the Markov chain saw | |
PerlMonks |
Re^2: cos (100000000.0)by bart (Canon) |
on Sep 02, 2009 at 07:59 UTC ( [id://792839]=note: print w/replies, xml ) | Need Help?? |
Why are you taking the cosine of 100 million radians? I cannot think of any valid reason for doing that. Amen to that. To the OP: trigonometric functions are about the most unreliable calculations that you can do on a computer. I think it is just not reasonable to expect very precise results, for such a huge parameter value. Actually, the difference in results between the different implementations is a lot smaller, than I had anticipated. Floating point in Perl has about 15 significant digits. For a function like cos, the digits before the decimal point don't really matter, as you may just as well use the parameter value modulo 2*PI, and (ideally) expect the same outcome. That means that for this parameter, with 8 digits wasted, you have about 6-7 significant digits left. That is how close you may expect the result of the calculation of cos to be. I am guessing you just made that parameter up, as a silly test.
In Section
Seekers of Perl Wisdom
|
|