Help for this page

Select Code to Download


  1. or download this
    use POSIX;
    sub round { floor($_[0] + 0.5) }
    
  2. or download this
    Benchmark: timing 100000 iterations of round1, round2...
        round1: 65 wallclock secs (64.59 usr +  0.00 sys = 64.59 CPU) @ 15
    +48.23/s (n=100000)
        round2: 47 wallclock secs (47.78 usr +  0.00 sys = 47.78 CPU) @ 20
    +92.93/s (n=100000)
    
  3. or download this
    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";
    }