void run_roundingmode_tests(void) { /* * Corner cases in other rounding modes. */ fesetround(FE_DOWNWARD); /* These are still positive per IEEE 754R */ #if 0 testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); #else /* logl, log2l, and log10l don't pass yet. */ test(log, 1.0, 0.0, ALL_STD_EXCEPT, 0); test(logf, 1.0, 0.0, ALL_STD_EXCEPT, 0); test(log2, 1.0, 0.0, ALL_STD_EXCEPT, 0); test(log2f, 1.0, 0.0, ALL_STD_EXCEPT, 0); test(log10, 1.0, 0.0, ALL_STD_EXCEPT, 0); test(log10f, 1.0, 0.0, ALL_STD_EXCEPT, 0); #endif testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); fesetround(FE_TOWARDZERO); testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); fesetround(FE_UPWARD); testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); /* log1p(-0.0) == -0.0 even when rounding upwards */ testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0); fesetround(FE_TONEAREST); }
void run_generic_tests(void) { /* log(1) == 0, no exceptions raised */ testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0); /* log(NaN) == NaN, no exceptions raised */ testall0(NAN, NAN, ALL_STD_EXCEPT, 0); testall1(NAN, NAN, ALL_STD_EXCEPT, 0); /* log(Inf) == Inf, no exceptions raised */ testall0(INFINITY, INFINITY, ALL_STD_EXCEPT, 0); testall1(INFINITY, INFINITY, ALL_STD_EXCEPT, 0); /* log(x) == NaN for x < 0, invalid exception raised */ testall0(-INFINITY, NAN, ALL_STD_EXCEPT, FE_INVALID); testall1(-INFINITY, NAN, ALL_STD_EXCEPT, FE_INVALID); testall0(-1.0, NAN, ALL_STD_EXCEPT, FE_INVALID); testall1(-1.5, NAN, ALL_STD_EXCEPT, FE_INVALID); /* log(0) == -Inf, divide-by-zero exception */ testall0(0.0, -INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_DIVBYZERO); testall0(-0.0, -INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_DIVBYZERO); testall1(-1.0, -INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_DIVBYZERO); }
void run_generic_tests(void) { /* exp(0) == 1, no exceptions raised */ testall0(0.0, 1.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); testall0(-0.0, 1.0, ALL_STD_EXCEPT, 0); testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0); /* exp(NaN) == NaN, no exceptions raised */ testall0(NAN, NAN, ALL_STD_EXCEPT, 0); testall1(NAN, NAN, ALL_STD_EXCEPT, 0); /* exp(Inf) == Inf, no exceptions raised */ testall0(INFINITY, INFINITY, ALL_STD_EXCEPT, 0); testall1(INFINITY, INFINITY, ALL_STD_EXCEPT, 0); /* exp(-Inf) == 0, no exceptions raised */ testall0(-INFINITY, 0.0, ALL_STD_EXCEPT, 0); testall1(-INFINITY, -1.0, ALL_STD_EXCEPT, 0); /* exp(big) == Inf, overflow exception */ testall0(50000.0, INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_OVERFLOW); testall1(50000.0, INFINITY, ALL_STD_EXCEPT & ~FE_INEXACT, FE_OVERFLOW); /* exp(small) == 0, underflow and inexact exceptions */ testall0(-50000.0, 0.0, ALL_STD_EXCEPT, FE_UNDERFLOW | FE_INEXACT); testall1(-50000.0, -1.0, ALL_STD_EXCEPT, FE_INEXACT); }
void run_roundingmode_tests(void) { /* * Corner cases in other rounding modes. */ fesetround(FE_DOWNWARD); /* These are still positive per IEEE 754R */ testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); fesetround(FE_TOWARDZERO); testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); fesetround(FE_UPWARD); testall0(1.0, 0.0, ALL_STD_EXCEPT, 0); testall1(0.0, 0.0, ALL_STD_EXCEPT, 0); /* log1p(-0.0) == -0.0 even when rounding upwards */ testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0); fesetround(FE_TONEAREST); }