Perl-Sensitive Sunglasses | |
PerlMonks |
Re: How do I round a number?by fundflow (Chaplain) |
on Jul 26, 2000 at 00:22 UTC ( [id://24343]=note: print w/replies, xml ) | Need Help?? |
The guy asked to round a number, the simplest way
is (my highschool teacher would be proud now..):
$rounded = int ( $orig + 0.5 )
This approach floors any decimal portion less than 0.5, and rounds up (in value) any decimal portion greater than .5. That means the following:
In Section
Seekers of Perl Wisdom
|
|