test_rational() fails

Issue #616 closed
Tey' created an issue

One of the unit tests in testdmath fails with HEAD version:

#!
.\testdmath.exe
src\tests\testdmath.cpp[70]       Rational(HNumber("-1235000")/HNumber("78950000")).toString().toStdString()      [NEW]
        Result   : -343/21927
        Expected : -247/15790
38 total, 1 failed, 1 new

I lack of time to find out which commit added this regression.

Comments (6)

  1. Pol Welter

    WOW...

    This is just becoming weirder....

    The constructor of Rational uses HMath::floor. It literally comes down to this very line (hmath.cpp[979]) again:

    if (HMath::abs(n - nearest_int) < HNumber("1e-70") * HMath::abs(n + nearest_int))
    

    Hadrien changed the tolerance to 1e-70 again (for good measure). That is what breaks Rational! In fact, we seem to require some value smaller than the resolution of SC. If I set it to 1e-100 it's fine.

    I give up. I have literally not the slightest idea what's going on there.

  2. Tey' reporter

    On a side note, reverting to 1e-1000 "fixes" this issue, which probably explains why the test failure didn't show up when we initially reviewed pull request #47. Still, that doesn't make sense.

  3. Log in to comment