go ahead... be a heretic | |
PerlMonks |
Re^2: int($x) gives strange resultby moritz (Cardinal) |
on Aug 24, 2009 at 08:16 UTC ( [id://790769]=note: print w/replies, xml ) | Need Help?? |
In general that's a very bad idea. If the number is larger, multiplying by 100.1 will severely skew the result:
So it turned 123456.15 into 123579.6 just to get rid of rounding errors - and produced errors which are about a thousand times larger. Instead you can add (not multiply) a small constant before calling int:
Depending on the range of the used numbers you'd have to think a bit more about the size of the small number you add.
Perl 6 projects - links to (nearly) everything that is Perl 6.
In Section
Seekers of Perl Wisdom
|
|