From: "Shawn H. Corey" <shawnhco...@gmail.com>
Octavian Râşniţă wrote:
Sorry but the calculation is obviously wrong. It is not my fault that the computers can't make a perfect float calculation with an infinite number of digits.
But yes, it is not just a fault of perl.

Since all the languages use the same math co-processor, they all get it wrong. The only question is when they tell you about it. That is, at what degree of precision do they round off? For Perl, this is a low number but you can use sprintf() to round off at a higher level.

See `perldoc perlfaq4` and search for /Does Perl have a round\(\) function\?/


I read it, and it doesn't sound very well:

"Rounding in financial applications can have serious implications, and
the rounding method used should be specified precisely. In these cases,
it probably pays not to trust whichever system rounding is being used by
Perl, but to instead implement the rounding function you need yourself."

It sounds like a limitation of perl because it makes the calculations at a too low level and not correct the errors automaticly, and not a limitation of computers in general, because PHP does it right, MS Excel does it right, the Windows Calculator does it right, so it is not something imposible to do automaticly.

Octavian


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to