in reply to cos (100000000.0)
Please read up on how floating point arithmatic works - for example What Every Computer Scientist Should Know About Floating-Point Arithmetic. I suspect that in C++ you are invoking the single precision cosine function (or maybe just the single-precision string format for output) and double precision in Java and Perl - doesn't it strike you as odd that it returns half as many digits? And I would like to know why you think any of those are more or less accurate - have you actually calculated the analytical answer? And what are you trying to do that requires 16 digits of precision - the Planck constant is only known to 8.
In short, what are you really trying to do? This sounds a lot like an XY Problem to me.
|
|---|