use POSIX; sub round { floor($_[0] + 0.5) } #### Benchmark: timing 100000 iterations of round1, round2... round1: 65 wallclock secs (64.59 usr + 0.00 sys = 64.59 CPU) @ 1548.23/s (n=100000) round2: 47 wallclock secs (47.78 usr + 0.00 sys = 47.78 CPU) @ 2092.93/s (n=100000) #### use Math::FixedPrecision; for (my $i = Math::FixedPrecision->new(0); $i <= 1; $i += 0.01) { print $i, "\t", Math::FixedPrecision->new($i + 0.01, 0), "\n"; }