That fails if $n is allready an integer. You would need something like:
my $n = 3.0; my $ceiling = int($n); $ceiling += 1 if $ceiling != $n;
Or as a one liner:
my $ceiling = int($n) + ($n != int($n));
In reply to Re^2: how to always round up in perl?
by chrestomanci
in thread how to always round up in perl?
by cburger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |