From 7cb029ee6ec74801aebe41af62d20a44775d0697 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 1 May 2012 15:37:43 +0000 Subject: Fix nexttoward bugs (bugs 2550, 2570). --- math/libm-test.inc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'math/libm-test.inc') diff --git a/math/libm-test.inc b/math/libm-test.inc index d643badfe2..0875e2c467 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -5743,8 +5743,73 @@ nexttoward_test (void) TEST_ff_f (nexttoward, 1.1L, nan_value, nan_value); TEST_ff_f (nexttoward, nan_value, nan_value, nan_value); - /* XXX We need the hexadecimal FP number representation here for further - tests. */ +#ifdef TEST_FLOAT + TEST_ff_f (nexttoward, 1.0, 1.1L, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, LDBL_MAX, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, 0x1.0000000000001p0, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, 0.9L, 0x0.ffffffp0); + TEST_ff_f (nexttoward, 1.0, -LDBL_MAX, 0x0.ffffffp0); + TEST_ff_f (nexttoward, 1.0, 0x0.fffffffffffff8p0, 0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, -1.1L, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -LDBL_MAX, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -0x1.0000000000001p0, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -0.9L, -0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, LDBL_MAX, -0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, -0x0.fffffffffffff8p0, -0x0.ffffffp0); + TEST_ff_f (nexttoward, -0x1.3p-145, -0xap-148L, -0x1.4p-145); +# if LDBL_MANT_DIG >= 64 + TEST_ff_f (nexttoward, 1.0, 0x1.000000000000002p0L, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffp0L, 0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, -0x1.000000000000002p0L, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffp0L, -0x0.ffffffp0); +# endif +# if LDBL_MANT_DIG >= 106 + TEST_ff_f (nexttoward, 1.0, 0x1.000000000000000000000000008p0L, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffffffffffffcp0L, 0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, -0x1.000000000000000000000000008p0L, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffffffffffffcp0L, -0x0.ffffffp0); +# endif +# if LDBL_MANT_DIG >= 113 + TEST_ff_f (nexttoward, 1.0, 0x1.0000000000000000000000000001p0L, 0x1.000002p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffffffffffffff8p0L, 0x0.ffffffp0); + TEST_ff_f (nexttoward, -1.0, -0x1.0000000000000000000000000001p0L, -0x1.000002p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffffffffffffff8p0L, -0x0.ffffffp0); +# endif +#endif +#ifdef TEST_DOUBLE + TEST_ff_f (nexttoward, 1.0, 1.1L, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, LDBL_MAX, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, 0x1.0000000000001p0, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, 0.9L, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, 1.0, -LDBL_MAX, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, 1.0, 0x0.fffffffffffff8p0, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -1.1L, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -LDBL_MAX, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -0x1.0000000000001p0, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -0.9L, -0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, LDBL_MAX, -0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -0x0.fffffffffffff8p0, -0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -0x8.00346dc5d6388p-3L, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, 0x1p-1074, 0x1p-1073L, 0x1p-1073); +# if LDBL_MANT_DIG >= 64 + TEST_ff_f (nexttoward, 1.0, 0x1.000000000000002p0L, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffp0L, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -0x1.000000000000002p0L, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffp0L, -0x0.fffffffffffff8p0); +# endif +# if LDBL_MANT_DIG >= 106 + TEST_ff_f (nexttoward, 1.0, 0x1.000000000000000000000000008p0L, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffffffffffffcp0L, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -0x1.000000000000000000000000008p0L, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffffffffffffcp0L, -0x0.fffffffffffff8p0); +# endif +# if LDBL_MANT_DIG >= 113 + TEST_ff_f (nexttoward, 1.0, 0x1.0000000000000000000000000001p0L, 0x1.0000000000001p0); + TEST_ff_f (nexttoward, 1.0, 0x0.ffffffffffffffffffffffffffff8p0L, 0x0.fffffffffffff8p0); + TEST_ff_f (nexttoward, -1.0, -0x1.0000000000000000000000000001p0L, -0x1.0000000000001p0); + TEST_ff_f (nexttoward, -1.0, -0x0.ffffffffffffffffffffffffffff8p0L, -0x0.fffffffffffff8p0); +# endif +#endif END (nexttoward); } -- cgit v1.2.1