in reply to Re^7: test fails on 64bit uselongdouble Perl
in thread test fails on 64bit uselongdouble Perl

Rounding to the nearest integers gives an error of +/- 1.0 even if the actual error is infinitesimally small. The OP said he's not ok with that.
  • Comment on Re^8: test fails on 64bit uselongdouble Perl

Replies are listed 'Best First'.
Re^9: test fails on 64bit uselongdouble Perl
by moritz (Cardinal) on Oct 30, 2009 at 07:29 UTC
    Rounding to the nearest integers gives an error of +/- 1.0 even if the actual error is infinitesimally small.

    I don't believe that. Care to explain?

    You do a calculation, and the result is an integer $n. Due to precision limits you get instead $n+$eps, where abs($eps) is small.

    Why wouldn't proper rounding return $n, but $n+1 or $n-1? At least that's how I understood your statement that it gives an error of +/- 1.0, which doesn't make sense to me at all.

    Perl 6 - links to (nearly) everything that is Perl 6.

      You do a calculation, and the result is an integer $n.

      Number $n. You haven't rounded to an integer yet.

      $n = 5.5; $eps = -0.00000000000001; printf "%.0f\n", $n; # 6 expected printf "%.0f\n", $n+$eps; # 5 get

      If his calculations are suppose to always give integers before rounding, then yes, there's no problem.