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/math.h | |
parent | 4775578486c8ee2aa09b402eb272eb932e7e0691 (diff) | |
download | glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.tar glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.tar.gz glibc-bb8081f57f23a3e1b28b1b7104f24d17da9a3d82.tar.bz2 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/math.h')
-rw-r--r-- | math/math.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/math/math.h b/math/math.h index 064cc56e1b..0a099596f1 100644 --- a/math/math.h +++ b/math/math.h @@ -331,6 +331,13 @@ enum /* Return nonzero value if X is subnormal. */ # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) + +/* Return nonzero value if X is zero. */ +# ifdef __SUPPORT_SNAN__ +# define iszero(x) (fpclassify (x) == FP_ZERO) +# else +# define iszero(x) ((x) == 0) +# endif #endif /* Use IEC_60559_BFP_EXT. */ #ifdef __USE_MISC |