P is for Practical | |
PerlMonks |
Re^2: Rounding off numbersby Tanalis (Curate) |
on Apr 20, 2006 at 14:36 UTC ( [id://544614]=note: print w/replies, xml ) | Need Help?? |
.. though it's important to remember that simply casting a float to an int, thus:
results in the decimal part of the number simply being truncated, giving an integer value with the above example of 2, not 3, which is possibly not what's expected. Update: Although, of course, adding the 0.5 to the number solves the problem nicely. Didn't see that in the post until just now .. -- Tanalis
In Section
Seekers of Perl Wisdom
|
|