|laziness, impatience, and hubris
Floating point problemsby bluescreen (Friar)
|on Oct 23, 2010 at 15:11 UTC
bluescreen has asked for the wisdom of the Perl Monks concerning the following question:
Hi, we recently found some oddity when it comes to how perl threats floating point numbers. For example:
Although I can workaround it using sprintf or use bignum. I don't understand why perl is intelligent enough to print 3773 when not using int but it is not smart enough to do same thing when using it. I know internally the number might be 3272.999999999999999 and so int chops off the decimal part but shouldn't be consistent?
This represent a legal problem for our application we rely heavily in maths for prizing and charges calculation.