How To Round Up A Number In Perl

To round up to the nearest 5:
1 2 |
use Math::Round qw(nhimult); $roundedUpNumber = nhimult( 5, $originalNumber ); |
http://search.cpan.org/dist/Math-Round/Round.pm
To round up to the nearest 1:
Cross-posted from PerlMonks:
1 2 3 4 |
sub roundUp { my $n = shift; return( $n == int($n) ? $n : int($n + 1) ); } |
Leave Your Comment
All fields marked with "*" are required.