in reply to Rounding without int() or printf()

The POSIX module contains functions called ceil and floor which return the first integer greater or less than a given number.

#!/usr/bin/perl -w use strict; use POSIX qw(ceil floor); my @numbers = qw(1 1.2 1.5 1.7 -1.2 -1.5 -1.7); foreach (@numbers) { printf("x: %.1f: ceil(x): %d floor(x) %d\n", $_, ceil($_), floor($_)); }
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me