Ignore:
Timestamp:
Jan 12, 2012, 12:36:29 AM (10 years ago)
Author:
sam
Message:

math: implement ulp() for reals, which returns the smallest real y > 0 such
that x + y != x, and nextafter() which behaves like the C function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/real.cpp

    r1122 r1130  
    241241        LOLUNIT_ASSERT_EQUAL((double)ldexp(a3, 7), 0.0);
    242242        LOLUNIT_ASSERT_EQUAL((double)ldexp(a3, -7), 0.0);
     243    }
     244
     245    LOLUNIT_TEST(Ulp)
     246    {
     247        real a1 = real::R_PI;
     248
     249        LOLUNIT_ASSERT_NOT_EQUAL((double)(a1 + ulp(a1) - a1), 0.0);
     250        LOLUNIT_ASSERT_EQUAL((double)(a1 + ulp(a1) / 2 - a1), 0.0);
    243251    }
    244252
Note: See TracChangeset for help on using the changeset viewer.