diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-09-23 21:54:21 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2016-09-23 21:54:21 +0000 |
commit | bb8081f57f23a3e1b28b1b7104f24d17da9a3d82 (patch) | |
tree | 0987589e19a174ecc1550dfc366813e6102973ef /math/libm-test.inc | |
parent | 4775578486c8ee2aa09b402eb272eb932e7e0691 (diff) | |
download | glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.tar.gz glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.tar.xz glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.zip |
Add iszero.
TS 18661-1 adds an iszero classification macro to <math.h>. This patch implements it for glibc. There are no new underlying functions in libm because the implementation uses fpclassify when sNaN support is required and a direct comparison otherwise; any optimizations for this macro should be done through adding __builtin_iszero in GCC and using it in the header for suitable GCC versions, not through adding other optimized inline or out-of-line versions to glibc. Tested for x86_64 and x86. * math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (iszero): New macro. * math/libm-test.inc (iszero_test_data): New array. (iszero_test): New function. (main): Call iszero_test. * manual/arith.texi (Floating Point Classes): Document iszero. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated.
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r-- | math/libm-test.inc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc index 385ec5c053..872bafd9c7 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -46,7 +46,7 @@ cbrt, ceil, copysign, cos, cosh, drem, erf, erfc, exp, exp10, exp2, expm1, fabs, fdim, finite, floor, fma, fmax, fmin, fmod, fpclassify, frexp, gamma, hypot, - ilogb, isfinite, isinf, isnan, isnormal, issignaling, issubnormal, + ilogb, isfinite, isinf, isnan, isnormal, issignaling, issubnormal, iszero, isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered, j0, j1, jn, ldexp, lgamma, log, log10, log1p, log2, logb, @@ -8671,6 +8671,31 @@ isunordered_test (void) ALL_RM_TEST (isunordered, 1, isunordered_test_data, RUN_TEST_LOOP_ff_i_tg, END); } +static const struct test_f_i_data iszero_test_data[] = + { + TEST_f_b (iszero, 0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, minus_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, 10, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, min_subnorm_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, -min_subnorm_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, -min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, max_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, -max_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, plus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, -qnan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_b (iszero, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + }; + +static void +iszero_test (void) +{ + ALL_RM_TEST (iszero, 1, iszero_test_data, RUN_TEST_LOOP_f_b_tg, END); +} + static const struct test_f_f_data j0_test_data[] = { /* j0 is the Bessel function of the first kind of order 0 */ @@ -12694,6 +12719,7 @@ main (int argc, char **argv) isnormal_test (); issignaling_test (); issubnormal_test (); + iszero_test (); signbit_test (); /* Trigonometric functions: */ |