in reply to how to always round up in perl?
Or if you do not want to import a mass of functions into your namespace from the POSIX module, just do this:
my $n = 3.3; my $ceiling = int($n + 1);
(Update) Above is incorrect, as pointed out by others. This works:
my $ceiling = ($n == int $n) ? $n : int($n + 1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to always round up in perl?
by chrestomanci (Priest) on Feb 25, 2011 at 09:19 UTC | |
by sbohning (Initiate) on Oct 11, 2021 at 17:01 UTC | |
|
Re^2: how to always round up in perl?
by Ratazong (Monsignor) on Feb 25, 2011 at 09:18 UTC | |
|
Re^2: how to always round up in perl? (selective import)
by toolic (Bishop) on Feb 25, 2011 at 14:25 UTC |