diff options
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r-- | math/libm-test.inc | 1053 |
1 files changed, 840 insertions, 213 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc index b144796f2a..b99255fd6d 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -3331,6 +3331,22 @@ llrint_test (void) TEST_f_L (llrint, -4503599627370496.75L, -4503599627370497LL); TEST_f_L (llrint, -4503599627370497.5L, -4503599627370498LL); +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 4503599627370495.4999999999999L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.4999999999999L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.4999999999999L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370494.5000000000001L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370495.5000000000001L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5000000000001L, 4503599627370497LL); + + TEST_f_L (llrint, -4503599627370495.4999999999999L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.4999999999999L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.4999999999999L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370494.5000000000001L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370495.5000000000001L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5000000000001L, -4503599627370497LL); +#endif + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740992LL); TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL); TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL); @@ -3343,6 +3359,22 @@ llrint_test (void) TEST_f_L (llrint, -9007199254740992.75L, -9007199254740993LL); TEST_f_L (llrint, -9007199254740993.5L, -9007199254740994LL); +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9007199254740991.4999999999999L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.4999999999999L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.4999999999999L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740991.5000000000001L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5000000000001L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5000000000001L, 9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.4999999999999L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.4999999999999L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.4999999999999L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740991.5000000000001L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5000000000001L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5000000000001L, -9007199254740994LL); +#endif + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927936LL); TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL); TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL); @@ -3354,11 +3386,570 @@ llrint_test (void) TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL); TEST_f_L (llrint, -72057594037927936.75L, -72057594037927937LL); TEST_f_L (llrint, -72057594037927937.5L, -72057594037927938LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9223372036854775805.5L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775805.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.0L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.0L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.25L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.25L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.5L, 9223372036854775806L); + TEST_f_L (llrint, -9223372036854775806.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.75L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775806.75L, -9223372036854775807LL); + TEST_f_L (llrint, 9223372036854775807.0L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775807.0L, -9223372036854775807LL); +# endif #endif END (llrint); } +static void +llrint_test_tonearest (void) +{ + int save_round_mode; + START (llrint_tonearest); + + save_round_mode = fegetround (); + + if (!fesetround (FE_TONEAREST)) + { + TEST_f_L (llrint, 0.0, 0); + TEST_f_L (llrint, minus_zero, 0); + TEST_f_L (llrint, 0.2L, 0); + TEST_f_L (llrint, -0.2L, 0); + + TEST_f_L (llrint, 1.4L, 1); + TEST_f_L (llrint, -1.4L, -1); + + TEST_f_L (llrint, 8388600.3L, 8388600); + TEST_f_L (llrint, -8388600.3L, -8388600); + + TEST_f_l (llrint, 1071930.0008, 1071930); + + /* Test boundary conditions. */ + /* 0x1FFFFF */ + TEST_f_L (llrint, 2097151.0,2097151LL); + /* 0x800000 */ + TEST_f_L (llrint, 8388608.0, 8388608LL); + /* 0x1000000 */ + TEST_f_L (llrint, 16777216.0, 16777216LL); + /* 0x20000000000 */ + TEST_f_L (llrint, 2199023255552.0, 2199023255552LL); + /* 0x40000000000 */ + TEST_f_L (llrint, 4398046511104.0, 4398046511104LL); + /* 0x1000000000000 */ + TEST_f_L (llrint, 281474976710656.0, 281474976710656LL); + /* 0x10000000000000 */ + TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL); + /* 0x10000080000000 */ + TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL); + /* 0x20000000000000 */ + TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL); + /* 0x80000000000000 */ + TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL); + /* 0x100000000000000 */ + TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL); +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llrint, 4503599627370495.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.25L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.75L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370497.5L, 4503599627370498LL); + + TEST_f_L (llrint, -4503599627370495.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.25L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.75L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370497.5L, -4503599627370498LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 4503599627370495.4999999999999L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.4999999999999L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.4999999999999L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370494.5000000000001L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370495.5000000000001L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5000000000001L, 4503599627370497LL); + + TEST_f_L (llrint, -4503599627370495.4999999999999L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.4999999999999L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.4999999999999L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370494.5000000000001L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370495.5000000000001L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5000000000001L, -4503599627370497LL); +#endif + + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.75L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5L, 9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.25L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.75L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5L, -9007199254740994LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9007199254740991.4999999999999L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.4999999999999L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.4999999999999L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740991.5000000000001L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5000000000001L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5000000000001L, 9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.4999999999999L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.4999999999999L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.4999999999999L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740991.5000000000001L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5000000000001L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5000000000001L, -9007199254740994LL); +#endif + + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.75L, 72057594037927937LL); + TEST_f_L (llrint, 72057594037927937.5L, 72057594037927938LL); + + TEST_f_L (llrint, -72057594037927935.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.25L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.75L, -72057594037927937LL); + TEST_f_L (llrint, -72057594037927937.5L, -72057594037927938LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9223372036854775805.5L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775805.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.0L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.0L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.25L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.25L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.5L, 9223372036854775806L); + TEST_f_L (llrint, -9223372036854775806.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.75L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775806.75L, -9223372036854775807LL); + TEST_f_L (llrint, 9223372036854775807.0L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775807.0L, -9223372036854775807LL); +# endif +#endif + } + + fesetround (save_round_mode); + + END (llrint_tonearest); +} + +static void +llrint_test_towardzero (void) +{ + int save_round_mode; + START (llrint_towardzero); + + save_round_mode = fegetround (); + + if (!fesetround (FE_TOWARDZERO)) + { + TEST_f_L (llrint, 0.0, 0); + TEST_f_L (llrint, minus_zero, 0); + TEST_f_L (llrint, 0.2L, 0); + TEST_f_L (llrint, -0.2L, 0); + + TEST_f_L (llrint, 1.4L, 1); + TEST_f_L (llrint, -1.4L, -1); + + TEST_f_L (llrint, 8388600.3L, 8388600); + TEST_f_L (llrint, -8388600.3L, -8388600); + + TEST_f_l (llrint, 1071930.0008, 1071930); + + /* Test boundary conditions. */ + /* 0x1FFFFF */ + TEST_f_L (llrint, 2097151.0,2097151LL); + /* 0x800000 */ + TEST_f_L (llrint, 8388608.0, 8388608LL); + /* 0x1000000 */ + TEST_f_L (llrint, 16777216.0, 16777216LL); + /* 0x20000000000 */ + TEST_f_L (llrint, 2199023255552.0, 2199023255552LL); + /* 0x40000000000 */ + TEST_f_L (llrint, 4398046511104.0, 4398046511104LL); + /* 0x1000000000000 */ + TEST_f_L (llrint, 281474976710656.0, 281474976710656LL); + /* 0x10000000000000 */ + TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL); + /* 0x10000080000000 */ + TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL); + /* 0x20000000000000 */ + TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL); + /* 0x80000000000000 */ + TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL); + /* 0x100000000000000 */ + TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL); +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llrint, 4503599627370495.5L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.25L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.75L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.5L, 4503599627370497LL); + + TEST_f_L (llrint, -4503599627370495.5L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.25L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.75L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.5L, -4503599627370497LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 4503599627370495.4999999999999L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.4999999999999L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.4999999999999L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370494.5000000000001L, 4503599627370494LL); + TEST_f_L (llrint, 4503599627370495.5000000000001L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.5000000000001L, 4503599627370496LL); + + TEST_f_L (llrint, -4503599627370495.4999999999999L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.4999999999999L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.4999999999999L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370494.5000000000001L, -4503599627370494LL); + TEST_f_L (llrint, -4503599627370495.5000000000001L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.5000000000001L, -4503599627370496LL); +#endif + + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.75L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.5L, 9007199254740993LL); + + TEST_f_L (llrint, -9007199254740991.5L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.25L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.75L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.5L, -9007199254740993LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9007199254740991.4999999999999L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.4999999999999L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.4999999999999L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740991.5000000000001L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.5000000000001L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.5000000000001L, 9007199254740993LL); + + TEST_f_L (llrint, -9007199254740991.4999999999999L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.4999999999999L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.4999999999999L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740991.5000000000001L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.5000000000001L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.5000000000001L, -9007199254740993LL); +#endif + + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927935LL); + TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.75L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927937.5L, 72057594037927937LL); + + TEST_f_L (llrint, -72057594037927935.5L, -72057594037927935LL); + TEST_f_L (llrint, -72057594037927936.25L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.75L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927937.5L, -72057594037927937LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9223372036854775805.5L, 9223372036854775805LL); + TEST_f_L (llrint, -9223372036854775805.5L, -9223372036854775805LL); + TEST_f_L (llrint, 9223372036854775806.0L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.0L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.25L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.25L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.5L, 9223372036854775806L); + TEST_f_L (llrint, -9223372036854775806.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.75L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.75L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775807.0L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775807.0L, -9223372036854775807LL); +# endif +#endif + } + + fesetround (save_round_mode); + + END (llrint_towardzero); +} + +static void +llrint_test_downward (void) +{ + int save_round_mode; + START (llrint_downward); + + save_round_mode = fegetround (); + + if (!fesetround (FE_DOWNWARD)) + { + TEST_f_L (llrint, 0.0, 0); + TEST_f_L (llrint, minus_zero, 0); + TEST_f_L (llrint, 0.2L, 0); + TEST_f_L (llrint, -0.2L, -1); + + TEST_f_L (llrint, 1.4L, 1); + TEST_f_L (llrint, -1.4L, -2); + + TEST_f_L (llrint, 8388600.3L, 8388600); + TEST_f_L (llrint, -8388600.3L, -8388601); + + TEST_f_l (llrint, 1071930.0008, 1071930); + + /* Test boundary conditions. */ + /* 0x1FFFFF */ + TEST_f_L (llrint, 2097151.0,2097151LL); + /* 0x800000 */ + TEST_f_L (llrint, 8388608.0, 8388608LL); + /* 0x1000000 */ + TEST_f_L (llrint, 16777216.0, 16777216LL); + /* 0x20000000000 */ + TEST_f_L (llrint, 2199023255552.0, 2199023255552LL); + /* 0x40000000000 */ + TEST_f_L (llrint, 4398046511104.0, 4398046511104LL); + /* 0x1000000000000 */ + TEST_f_L (llrint, 281474976710656.0, 281474976710656LL); + /* 0x10000000000000 */ + TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL); + /* 0x10000080000000 */ + TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL); + /* 0x20000000000000 */ + TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL); + /* 0x80000000000000 */ + TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL); + /* 0x100000000000000 */ + TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL); +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llrint, 4503599627370495.5L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.25L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.75L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.5L, 4503599627370497LL); + + TEST_f_L (llrint, 4503599627370495.4999999999999L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.4999999999999L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370497.4999999999999L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370494.5000000000001L, 4503599627370494LL); + TEST_f_L (llrint, 4503599627370495.5000000000001L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370496.5000000000001L, 4503599627370496LL); + + TEST_f_L (llrint, -4503599627370495.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.25L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370496.5L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370496.75L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370497.5L, -4503599627370498LL); + + TEST_f_L (llrint, -4503599627370495.4999999999999L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.4999999999999L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370497.4999999999999L, -4503599627370498LL); + TEST_f_L (llrint, -4503599627370494.5000000000001L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370495.5000000000001L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5000000000001L, -4503599627370497LL); + + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.75L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.5L, 9007199254740993LL); + + TEST_f_L (llrint, 9007199254740991.4999999999999L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.4999999999999L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.4999999999999L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740991.5000000000001L, 9007199254740991LL); + TEST_f_L (llrint, 9007199254740992.5000000000001L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740993.5000000000001L, 9007199254740993LL); + + TEST_f_L (llrint, -9007199254740991.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.25L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740992.5L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740992.75L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5L, -9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.4999999999999L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.4999999999999L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.4999999999999L, -9007199254740994LL); + TEST_f_L (llrint, -9007199254740991.5000000000001L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5000000000001L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5000000000001L, -9007199254740994LL); + + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927935LL); + TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.75L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927937.5L, 72057594037927937LL); + + TEST_f_L (llrint, -72057594037927935.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.25L, -72057594037927937LL); + TEST_f_L (llrint, -72057594037927936.5L, -72057594037927937LL); + TEST_f_L (llrint, -72057594037927936.75L, -72057594037927937LL); + TEST_f_L (llrint, -72057594037927937.5L, -72057594037927938LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9223372036854775805.5L, 9223372036854775805LL); + TEST_f_L (llrint, -9223372036854775805.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.0L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.0L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.25L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.25L, -9223372036854775807LL); + TEST_f_L (llrint, 9223372036854775806.5L, 9223372036854775806L); + TEST_f_L (llrint, -9223372036854775806.5L, -9223372036854775807LL); + TEST_f_L (llrint, 9223372036854775806.75L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.75L, -9223372036854775807LL); + TEST_f_L (llrint, 9223372036854775807.0L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775807.0L, -9223372036854775807LL); +# endif +#endif + } + + fesetround (save_round_mode); + + END (llrint_downward); +} + +static void +llrint_test_upward (void) +{ + int save_round_mode; + START (llrint_upward); + + save_round_mode = fegetround (); + + if (!fesetround (FE_UPWARD)) + { + TEST_f_L (llrint, 0.0, 0); + TEST_f_L (llrint, minus_zero, 0); + TEST_f_L (llrint, 0.2L, 1); + TEST_f_L (llrint, -0.2L, 0); + + TEST_f_L (llrint, 1.4L, 2); + TEST_f_L (llrint, -1.4L, -1); + + TEST_f_L (llrint, 8388600.3L, 8388601); + TEST_f_L (llrint, -8388600.3L, -8388600); +#ifndef TEST_FLOAT + TEST_f_l (llrint, 1071930.0008, 1071931); +#endif + /* Test boundary conditions. */ + /* 0x1FFFFF */ + TEST_f_L (llrint, 2097151.0,2097151LL); + /* 0x800000 */ + TEST_f_L (llrint, 8388608.0, 8388608LL); + /* 0x1000000 */ + TEST_f_L (llrint, 16777216.0, 16777216LL); + /* 0x20000000000 */ + TEST_f_L (llrint, 2199023255552.0, 2199023255552LL); + /* 0x40000000000 */ + TEST_f_L (llrint, 4398046511104.0, 4398046511104LL); + /* 0x1000000000000 */ + TEST_f_L (llrint, 281474976710656.0, 281474976710656LL); + /* 0x10000000000000 */ + TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL); + /* 0x10000080000000 */ + TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL); + /* 0x20000000000000 */ + TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL); + /* 0x80000000000000 */ + TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL); + /* 0x100000000000000 */ + TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL); +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llrint, 4503599627370495.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.25L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370496.5L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370496.75L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370497.5L, 4503599627370498LL); + + TEST_f_L (llrint, 4503599627370495.4999999999999L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.4999999999999L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370497.4999999999999L, 4503599627370498LL); + TEST_f_L (llrint, 4503599627370494.5000000000001L, 4503599627370495LL); + TEST_f_L (llrint, 4503599627370495.5000000000001L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5000000000001L, 4503599627370497LL); + + TEST_f_L (llrint, -4503599627370495.5L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.25L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.75L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.5L, -4503599627370497LL); + + TEST_f_L (llrint, -4503599627370495.4999999999999L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.4999999999999L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370497.4999999999999L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370494.5000000000001L, -4503599627370494LL); + TEST_f_L (llrint, -4503599627370495.5000000000001L, -4503599627370495LL); + TEST_f_L (llrint, -4503599627370496.5000000000001L, -4503599627370496LL); + + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.25L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740992.5L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740992.75L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5L, 9007199254740994LL); + + TEST_f_L (llrint, 9007199254740991.4999999999999L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.4999999999999L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.4999999999999L, 9007199254740994LL); + TEST_f_L (llrint, 9007199254740991.5000000000001L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5000000000001L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5000000000001L, 9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.5L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.25L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.75L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.5L, -9007199254740993LL); + + TEST_f_L (llrint, -9007199254740991.4999999999999L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.4999999999999L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.4999999999999L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740991.5000000000001L, -9007199254740991LL); + TEST_f_L (llrint, -9007199254740992.5000000000001L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740993.5000000000001L, -9007199254740993LL); + + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.25L, 72057594037927937LL); + TEST_f_L (llrint, 72057594037927936.5L, 72057594037927937LL); + TEST_f_L (llrint, 72057594037927936.75L, 72057594037927937LL); + TEST_f_L (llrint, 72057594037927937.5L, 72057594037927938LL); + + TEST_f_L (llrint, -72057594037927935.5L, -72057594037927935LL); + TEST_f_L (llrint, -72057594037927936.25L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.75L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927937.5L, -72057594037927937LL); + +# if LDBL_MANT_DIG > 100 + TEST_f_L (llrint, 9223372036854775805.5L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775805.5L, -9223372036854775805LL); + TEST_f_L (llrint, 9223372036854775806.0L, 9223372036854775806LL); + TEST_f_L (llrint, -9223372036854775806.0L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.25L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775806.25L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.5L, 9223372036854775807L); + TEST_f_L (llrint, -9223372036854775806.5L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775806.75L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775806.75L, -9223372036854775806LL); + TEST_f_L (llrint, 9223372036854775807.0L, 9223372036854775807LL); + TEST_f_L (llrint, -9223372036854775807.0L, -9223372036854775807LL); +# endif +#endif + } + + fesetround (save_round_mode); + + END (llrint_upward); +} + static void log_test (void) @@ -3597,6 +4188,22 @@ llround_test (void) TEST_f_L (llround, 4503599627370496.75L, 4503599627370497LL); TEST_f_L (llround, 4503599627370497.5L, 4503599627370498LL); +# if LDBL_MANT_DIG > 100 + TEST_f_L (llround, 4503599627370495.4999999999999L, 4503599627370495LL); + TEST_f_L (llround, 4503599627370496.4999999999999L, 4503599627370496LL); + TEST_f_L (llround, 4503599627370497.4999999999999L, 4503599627370497LL); + TEST_f_L (llround, 4503599627370494.5000000000001L, 4503599627370495LL); + TEST_f_L (llround, 4503599627370495.5000000000001L, 4503599627370496LL); + TEST_f_L (llround, 4503599627370496.5000000000001L, 4503599627370497LL); + + TEST_f_L (llround, -4503599627370495.4999999999999L, -4503599627370495LL); + TEST_f_L (llround, -4503599627370496.4999999999999L, -4503599627370496LL); + TEST_f_L (llround, -4503599627370497.4999999999999L, -4503599627370497LL); + TEST_f_L (llround, -4503599627370494.5000000000001L, -4503599627370495LL); + TEST_f_L (llround, -4503599627370495.5000000000001L, -4503599627370496LL); + TEST_f_L (llround, -4503599627370496.5000000000001L, -4503599627370497LL); +# endif + TEST_f_L (llround, -4503599627370495.5L, -4503599627370496LL); TEST_f_L (llround, -4503599627370496.25L, -4503599627370496LL); TEST_f_L (llround, -4503599627370496.5L, -4503599627370497LL); @@ -3609,6 +4216,22 @@ llround_test (void) TEST_f_L (llround, 9007199254740992.75L, 9007199254740993LL); TEST_f_L (llround, 9007199254740993.5L, 9007199254740994LL); +# if LDBL_MANT_DIG > 100 + TEST_f_L (llround, 9007199254740991.4999999999999L, 9007199254740991LL); + TEST_f_L (llround, 9007199254740992.4999999999999L, 9007199254740992LL); + TEST_f_L (llround, 9007199254740993.4999999999999L, 9007199254740993LL); + TEST_f_L (llround, 9007199254740991.5000000000001L, 9007199254740992LL); + TEST_f_L (llround, 9007199254740992.5000000000001L, 9007199254740993LL); + TEST_f_L (llround, 9007199254740993.5000000000001L, 9007199254740994LL); + + TEST_f_L (llround, -9007199254740991.4999999999999L, -9007199254740991LL); + TEST_f_L (llround, -9007199254740992.4999999999999L, -9007199254740992LL); + TEST_f_L (llround, -9007199254740993.4999999999999L, -9007199254740993LL); + TEST_f_L (llround, -9007199254740991.5000000000001L, -9007199254740992LL); + TEST_f_L (llround, -9007199254740992.5000000000001L, -9007199254740993LL); + TEST_f_L (llround, -9007199254740993.5000000000001L, -9007199254740994LL); +# endif + TEST_f_L (llround, -9007199254740991.5L, -9007199254740992LL); TEST_f_L (llround, -9007199254740992.25L, -9007199254740992LL); TEST_f_L (llround, -9007199254740992.5L, -9007199254740993LL); @@ -4044,7 +4667,7 @@ rint_test (void) TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); - + # if LDBL_MANT_DIG > 100 TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370495.0L); TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370496.0L); @@ -4056,7 +4679,7 @@ rint_test (void) TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); - + # if LDBL_MANT_DIG > 100 TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370495.0L); TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370496.0L); @@ -4117,66 +4740,66 @@ rint_test_tonearest (void) int save_round_mode; START (rint_tonearest); - save_round_mode = fegetround(); + save_round_mode = fegetround (); if (!fesetround (FE_TONEAREST)) - { - TEST_f_f (rint, 2.0, 2.0); - TEST_f_f (rint, 1.5, 2.0); - TEST_f_f (rint, 1.0, 1.0); - TEST_f_f (rint, 0.5, 0.0); - TEST_f_f (rint, 0.0, 0.0); - TEST_f_f (rint, minus_zero, minus_zero); - TEST_f_f (rint, -0.5, -0.0); - TEST_f_f (rint, -1.0, -1.0); - TEST_f_f (rint, -1.5, -2.0); - TEST_f_f (rint, -2.0, -2.0); - TEST_f_f (rint, 0.1, 0.0); - TEST_f_f (rint, 0.25, 0.0); - TEST_f_f (rint, 0.625, 1.0); - TEST_f_f (rint, -0.1, -0.0); - TEST_f_f (rint, -0.25, -0.0); - TEST_f_f (rint, -0.625, -1.0); + { + TEST_f_f (rint, 2.0, 2.0); + TEST_f_f (rint, 1.5, 2.0); + TEST_f_f (rint, 1.0, 1.0); + TEST_f_f (rint, 0.5, 0.0); + TEST_f_f (rint, 0.0, 0.0); + TEST_f_f (rint, minus_zero, minus_zero); + TEST_f_f (rint, -0.5, -0.0); + TEST_f_f (rint, -1.0, -1.0); + TEST_f_f (rint, -1.5, -2.0); + TEST_f_f (rint, -2.0, -2.0); + TEST_f_f (rint, 0.1, 0.0); + TEST_f_f (rint, 0.25, 0.0); + TEST_f_f (rint, 0.625, 1.0); + TEST_f_f (rint, -0.1, -0.0); + TEST_f_f (rint, -0.25, -0.0); + TEST_f_f (rint, -0.625, -1.0); #ifdef TEST_LDOUBLE - /* The result can only be represented in long double. */ - TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); - TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); + /* The result can only be represented in long double. */ + TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370497.0L); # endif - TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); - TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); + TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370497.0L); - - TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); - TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740994.0L); - - TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); - TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740994.0L); + TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370497.0L); + + TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); + TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740994.0L); + + TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); + TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740994.0L); # endif #endif - } + } - fesetround(save_round_mode); + fesetround (save_round_mode); END (rint_tonearest); } @@ -4187,66 +4810,66 @@ rint_test_towardzero (void) int save_round_mode; START (rint_towardzero); - save_round_mode = fegetround(); + save_round_mode = fegetround (); if (!fesetround (FE_TOWARDZERO)) - { - TEST_f_f (rint, 2.0, 2.0); - TEST_f_f (rint, 1.5, 1.0); - TEST_f_f (rint, 1.0, 1.0); - TEST_f_f (rint, 0.5, 0.0); - TEST_f_f (rint, 0.0, 0.0); - TEST_f_f (rint, minus_zero, minus_zero); - TEST_f_f (rint, -0.5, -0.0); - TEST_f_f (rint, -1.0, -1.0); - TEST_f_f (rint, -1.5, -1.0); - TEST_f_f (rint, -2.0, -2.0); - TEST_f_f (rint, 0.1, 0.0); - TEST_f_f (rint, 0.25, 0.0); - TEST_f_f (rint, 0.625, 0.0); - TEST_f_f (rint, -0.1, -0.0); - TEST_f_f (rint, -0.25, -0.0); - TEST_f_f (rint, -0.625, -0.0); + { + TEST_f_f (rint, 2.0, 2.0); + TEST_f_f (rint, 1.5, 1.0); + TEST_f_f (rint, 1.0, 1.0); + TEST_f_f (rint, 0.5, 0.0); + TEST_f_f (rint, 0.0, 0.0); + TEST_f_f (rint, minus_zero, minus_zero); + TEST_f_f (rint, -0.5, -0.0); + TEST_f_f (rint, -1.0, -1.0); + TEST_f_f (rint, -1.5, -1.0); + TEST_f_f (rint, -2.0, -2.0); + TEST_f_f (rint, 0.1, 0.0); + TEST_f_f (rint, 0.25, 0.0); + TEST_f_f (rint, 0.625, 0.0); + TEST_f_f (rint, -0.1, -0.0); + TEST_f_f (rint, -0.25, -0.0); + TEST_f_f (rint, -0.625, -0.0); #ifdef TEST_LDOUBLE - /* The result can only be represented in long double. */ - TEST_f_f (rint, 4503599627370495.5L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.75L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370497.5L, 4503599627370497.0L); + /* The result can only be represented in long double. */ + TEST_f_f (rint, 4503599627370495.5L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.75L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370497.5L, 4503599627370497.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370494.0L); - TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370494.0L); + TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370496.0L); # endif - TEST_f_f (rint, -4503599627370495.5L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.75L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370497.5L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370495.5L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.75L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370497.5L, -4503599627370497.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370494.0L); - TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370496.0L); - - TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); - TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740991.0L); - TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740993.0L); - - TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); - TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740991.0L); - TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370494.0L); + TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370496.0L); + + TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); + TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740991.0L); + TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740993.0L); + + TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); + TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740991.0L); + TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740993.0L); # endif #endif - } + } - fesetround(save_round_mode); + fesetround (save_round_mode); END (rint_towardzero); } @@ -4257,66 +4880,66 @@ rint_test_downward (void) int save_round_mode; START (rint_downward); - save_round_mode = fegetround(); + save_round_mode = fegetround (); if (!fesetround (FE_DOWNWARD)) - { - TEST_f_f (rint, 2.0, 2.0); - TEST_f_f (rint, 1.5, 1.0); - TEST_f_f (rint, 1.0, 1.0); - TEST_f_f (rint, 0.5, 0.0); - TEST_f_f (rint, 0.0, 0.0); - TEST_f_f (rint, minus_zero, minus_zero); - TEST_f_f (rint, -0.5, -1.0); - TEST_f_f (rint, -1.0, -1.0); - TEST_f_f (rint, -1.5, -2.0); - TEST_f_f (rint, -2.0, -2.0); - TEST_f_f (rint, 0.1, 0.0); - TEST_f_f (rint, 0.25, 0.0); - TEST_f_f (rint, 0.625, 0.0); - TEST_f_f (rint, -0.1, -1.0); - TEST_f_f (rint, -0.25, -1.0); - TEST_f_f (rint, -0.625, -1.0); + { + TEST_f_f (rint, 2.0, 2.0); + TEST_f_f (rint, 1.5, 1.0); + TEST_f_f (rint, 1.0, 1.0); + TEST_f_f (rint, 0.5, 0.0); + TEST_f_f (rint, 0.0, 0.0); + TEST_f_f (rint, minus_zero, minus_zero); + TEST_f_f (rint, -0.5, -1.0); + TEST_f_f (rint, -1.0, -1.0); + TEST_f_f (rint, -1.5, -2.0); + TEST_f_f (rint, -2.0, -2.0); + TEST_f_f (rint, 0.1, 0.0); + TEST_f_f (rint, 0.25, 0.0); + TEST_f_f (rint, 0.625, 0.0); + TEST_f_f (rint, -0.1, -1.0); + TEST_f_f (rint, -0.25, -1.0); + TEST_f_f (rint, -0.625, -1.0); #ifdef TEST_LDOUBLE - /* The result can only be represented in long double. */ - TEST_f_f (rint, 4503599627370495.5L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.75L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370497.5L, 4503599627370497.0L); + /* The result can only be represented in long double. */ + TEST_f_f (rint, 4503599627370495.5L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.75L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370497.5L, 4503599627370497.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370494.0L); - TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370494.0L); + TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370496.0L); # endif - TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.25L, -4503599627370497.0L); - TEST_f_f (rint, -4503599627370496.5L, -4503599627370497.0L); - TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); - TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); + TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.25L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370496.5L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370497.0L); - - TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); - TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740991.0L); - TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740993.0L); - - TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740994.0L); - TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740994.0L); + TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370497.0L); + + TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740991.0L); + TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740991.0L); + TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740993.0L); + + TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740994.0L); + TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740994.0L); # endif #endif - } + } - fesetround(save_round_mode); + fesetround (save_round_mode); END (rint_downward); } @@ -4327,66 +4950,66 @@ rint_test_upward (void) int save_round_mode; START (rint_upward); - save_round_mode = fegetround(); + save_round_mode = fegetround (); if (!fesetround (FE_UPWARD)) - { - TEST_f_f (rint, 2.0, 2.0); - TEST_f_f (rint, 1.5, 2.0); - TEST_f_f (rint, 1.0, 1.0); - TEST_f_f (rint, 0.5, 1.0); - TEST_f_f (rint, 0.0, 0.0); - TEST_f_f (rint, minus_zero, minus_zero); - TEST_f_f (rint, -0.5, -0.0); - TEST_f_f (rint, -1.0, -1.0); - TEST_f_f (rint, -1.5, -1.0); - TEST_f_f (rint, -2.0, -2.0); - TEST_f_f (rint, 0.1, 1.0); - TEST_f_f (rint, 0.25, 1.0); - TEST_f_f (rint, 0.625, 1.0); - TEST_f_f (rint, -0.1, -0.0); - TEST_f_f (rint, -0.25, -0.0); - TEST_f_f (rint, -0.625, -0.0); + { + TEST_f_f (rint, 2.0, 2.0); + TEST_f_f (rint, 1.5, 2.0); + TEST_f_f (rint, 1.0, 1.0); + TEST_f_f (rint, 0.5, 1.0); + TEST_f_f (rint, 0.0, 0.0); + TEST_f_f (rint, minus_zero, minus_zero); + TEST_f_f (rint, -0.5, -0.0); + TEST_f_f (rint, -1.0, -1.0); + TEST_f_f (rint, -1.5, -1.0); + TEST_f_f (rint, -2.0, -2.0); + TEST_f_f (rint, 0.1, 1.0); + TEST_f_f (rint, 0.25, 1.0); + TEST_f_f (rint, 0.625, 1.0); + TEST_f_f (rint, -0.1, -0.0); + TEST_f_f (rint, -0.25, -0.0); + TEST_f_f (rint, -0.625, -0.0); #ifdef TEST_LDOUBLE - /* The result can only be represented in long double. */ - TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.25L, 4503599627370497.0L); - TEST_f_f (rint, 4503599627370496.5L, 4503599627370497.0L); - TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); - TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); + /* The result can only be represented in long double. */ + TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.25L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370496.5L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370495.0L); - TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370496.0L); - TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370494.5000000000001L, 4503599627370495.0L); + TEST_f_f (rint, 4503599627370495.5000000000001L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5000000000001L, 4503599627370497.0L); # endif - TEST_f_f (rint, -4503599627370495.5L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370496.75L, -4503599627370496.0L); - TEST_f_f (rint, -4503599627370497.5L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370495.5L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.75L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370497.5L, -4503599627370497.0L); # if LDBL_MANT_DIG > 100 - TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370494.0L); - TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370495.0L); - TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370496.0L); - - TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740994.0L); - TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740992.0L); - TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740993.0L); - TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740994.0L); - - TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); - TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); - TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740991.0L); - TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740992.0L); - TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -4503599627370494.5000000000001L, -4503599627370494.0L); + TEST_f_f (rint, -4503599627370495.5000000000001L, -4503599627370495.0L); + TEST_f_f (rint, -4503599627370496.5000000000001L, -4503599627370496.0L); + + TEST_f_f (rint, 9007199254740991.0000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.0000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740993.0000000000001L, 9007199254740994.0L); + TEST_f_f (rint, 9007199254740991.5000000000001L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.5000000000001L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740993.5000000000001L, 9007199254740994.0L); + + TEST_f_f (rint, -9007199254740991.0000000000001L, -9007199254740991.0L); + TEST_f_f (rint, -9007199254740992.0000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740993.0000000000001L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740991.5000000000001L, -9007199254740991.0L); + TEST_f_f (rint, -9007199254740992.5000000000001L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740993.5000000000001L, -9007199254740993.0L); # endif #endif - } + } - fesetround(save_round_mode); + fesetround (save_round_mode); END (rint_upward); } @@ -4419,7 +5042,7 @@ round_test (void) /* The result can only be represented in long double. */ TEST_f_f (round, 4503599627370495.5L, 4503599627370496.0L); TEST_f_f (round, 4503599627370496.25L, 4503599627370496.0L); - TEST_f_f (round, 4503599627370496.5L, 4503599627370497.0L); + TEST_f_f (round, 4503599627370496.5L, 4503599627370497.0L); TEST_f_f (round, 4503599627370496.75L, 4503599627370497.0L); TEST_f_f (round, 4503599627370497.5L, 4503599627370498.0L); # if LDBL_MANT_DIG > 100 @@ -4428,10 +5051,10 @@ round_test (void) TEST_f_f (round, 4503599627370496.5000000000001L, 4503599627370497.0L); # endif - TEST_f_f (round, -4503599627370495.5L, -4503599627370496.0L); - TEST_f_f (round, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (round, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (round, -4503599627370496.25L, -4503599627370496.0L); TEST_f_f (round, -4503599627370496.5L, -4503599627370497.0L); - TEST_f_f (round, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (round, -4503599627370496.75L, -4503599627370497.0L); TEST_f_f (round, -4503599627370497.5L, -4503599627370498.0L); # if LDBL_MANT_DIG > 100 TEST_f_f (round, -4503599627370494.5000000000001L, -4503599627370495.0L); @@ -4870,13 +5493,13 @@ trunc_test (void) TEST_f_f (trunc, 4503599627370495.5000000000001L, 4503599627370495.0L); TEST_f_f (trunc, 4503599627370496.5000000000001L, 4503599627370496.0L); # endif - + TEST_f_f (trunc, -4503599627370495.5L, -4503599627370495.0L); TEST_f_f (trunc, -4503599627370496.25L, -4503599627370496.0L); TEST_f_f (trunc, -4503599627370496.5L, -4503599627370496.0L); TEST_f_f (trunc, -4503599627370496.75L, -4503599627370496.0L); TEST_f_f (trunc, -4503599627370497.5L, -4503599627370497.0L); - + # if LDBL_MANT_DIG > 100 TEST_f_f (trunc, -4503599627370494.5000000000001L, -4503599627370494.0L); TEST_f_f (trunc, -4503599627370495.5000000000001L, -4503599627370495.0L); @@ -4929,7 +5552,7 @@ trunc_test (void) TEST_f_f (trunc, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L); TEST_f_f (trunc, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L); TEST_f_f (trunc, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L); - TEST_f_f (trunc, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L); + TEST_f_f (trunc, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L); #endif END (trunc); @@ -5315,6 +5938,10 @@ main (int argc, char **argv) rint_test_upward (); lrint_test (); llrint_test (); + llrint_test_tonearest (); + llrint_test_towardzero (); + llrint_test_downward (); + llrint_test_upward (); round_test (); lround_test (); llround_test (); |