Problems? Is your data what you think it is? | |
PerlMonks |
Re: Why does perl math suck?by tilly (Archbishop) |
on Jan 29, 2011 at 15:39 UTC ( [id://885026]=note: print w/replies, xml ) | Need Help?? |
perl -le 'print 5056.45 + 10112.92 eq 15169.37 ? "as expected" : "perl math sucks!"'
works as expected. The reason is that Perl uses more digits in floating point calculations than it stringifies, so stringification rounds off to the expected number. (I didn't invent this trick.)
In Section
Seekers of Perl Wisdom
|
|