Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libm/common/s_isnan.c')
-rw-r--r--newlib/libm/common/s_isnan.c113
1 files changed, 92 insertions, 21 deletions
diff --git a/newlib/libm/common/s_isnan.c b/newlib/libm/common/s_isnan.c
index b0c40369a..5ae6c9b81 100644
--- a/newlib/libm/common/s_isnan.c
+++ b/newlib/libm/common/s_isnan.c
@@ -13,8 +13,21 @@
/*
FUNCTION
- <<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers
+<<fpclassify>>, <<isfinite>>, <<isinf>>, <<isnan>>, and <<isnormal>>--floating-point classification macros; <<finite>>, <<finitef>>, <<isinf>>, <<isinff>>, <<isnan>>, <<isnanf>>--test for exceptional numbers
+@c C99 (start
+INDEX
+ fpclassify
+INDEX
+ isfinite
+INDEX
+ isinf
+INDEX
+ isnan
+INDEX
+ isnormal
+@c C99 end)
+@c SUSv2 (start
INDEX
isnan
INDEX
@@ -28,8 +41,18 @@ INDEX
isinff
INDEX
finitef
+@c SUSv2 end)
ANSI_SYNOPSIS
+ [C99 standard macros:]
+ #include <math.h>
+ int fpclassify(real-floating <[x]>);
+ int isfinite(real-floating <[x]>);
+ int isinf(real-floating <[x]>);
+ int isnan(real-floating <[x]>);
+ int isnormal(real-floating <[x]>);
+
+ [Archaic SUSv2 functions:]
#include <ieeefp.h>
int isnan(double <[arg]>);
int isinf(double <[arg]>);
@@ -38,30 +61,64 @@ ANSI_SYNOPSIS
int isinff(float <[arg]>);
int finitef(float <[arg]>);
-TRAD_SYNOPSIS
- #include <ieeefp.h>
- int isnan(<[arg]>)
- double <[arg]>;
- int isinf(<[arg]>)
- double <[arg]>;
- int finite(<[arg]>);
- double <[arg]>;
- int isnanf(<[arg]>);
- float <[arg]>;
- int isinff(<[arg]>);
- float <[arg]>;
- int finitef(<[arg]>);
- float <[arg]>;
-
-
DESCRIPTION
- These functions provide information on the floating-point
+<<fpclassify>>, <<isfinite>>, <<isinf>>, <<isnan>>, and <<isnormal>> are macros
+defined for use in classifying floating-point numbers. This is a help because
+of special "values" like NaN and infinities. In the synopses shown,
+"real-floating" indicates that the argument is an expression of real floating
+type. These function-like macros are C99 and POSIX-compliant, and should be
+used instead of the now-archaic SUSv2 functions.
+
+The <<fpclassify>> macro classifies its argument value as NaN, infinite, normal,
+subnormal, zero, or into another implementation-defined category. First, an
+argument represented in a format wider than its semantic type is converted to
+its semantic type. Then classification is based on the type of the argument.
+The <<fpclassify>> macro returns the value of the number classification macro
+appropriate to the value of its argument:
+
+o+
+o FP_INFINITE
+ <[x]> is either plus or minus infinity;
+o FP_NAN
+ <[x]> is "Not A Number" (plus or minus);
+o FP_NORMAL
+ <[x]> is a "normal" number (i.e. is none of the other special forms);
+o FP_SUBNORMAL
+ <[x]> is too small be stored as a regular normalized number (i.e. loss of precision is likely); or
+o FP_ZERO
+ <[x]> is 0 (either plus or minus).
+o-
+
+The "<<is>>" set of macros provide a useful set of shorthand ways for
+classifying floating-point numbers, providing the following equivalent
+relations:
+
+o+
+o <<isfinite>>(<[x]>)
+returns non-zero if <[x]> is finite. (It is equivalent to
+(<<fpclassify>>(<[x]>) != FP_INFINITE && <<fpclassify>>(<[x]>) != FP_NAN).)
+
+o <<isinf>>(<[x]>)
+returns non-zero if <[x]> is infinite. (It is equivalent to
+(<<fpclassify>>(<[x]>) == FP_INFINITE).)
+
+o <<isnan>>(<[x]>)
+returns non-zero if <[x]> is NaN. (It is equivalent to
+(<<fpclassify>>(<[x]>) == FP_NAN).)
+
+o <<isnormal>>(<[x]>)
+returns non-zero if <[x]> is normal. (It is equivalent to
+(<<fpclassify>>(<[x]>) == FP_NORMAL).)
+o-
+
+ The archaic SUSv2 functions provide information on the floating-point
argument supplied.
- There are five major number formats:
+ There are five major number formats ("exponent" referring to the
+ biased exponent in the binary-encoded number):
o+
o zero
- A number which contains all zero bits.
+ A number which contains all zero bits, excluding the sign bit.
o subnormal
A number with a zero exponent but a nonzero fraction.
o normal
@@ -85,7 +142,21 @@ DESCRIPTION
and <<isinf>> are macros that operate on multiple types of
floating-point. The SUSv2 standard declares <<isnan>> as
a function taking double. Newlib has decided to declare
- them both as macros in math.h and as functions in ieeefp.h.
+ them both as macros in math.h and as functions in ieeefp.h to
+ maintain backward compatibility.
+
+RETURNS
+@comment Formatting note: "$@" forces a new line
+The fpclassify macro returns the value corresponding to the appropriate FP_ macro.@*
+The isfinite macro returns nonzero if <[x]> is finite, else 0.@*
+The isinf macro returns nonzero if <[x]> is infinite, else 0.@*
+The isnan macro returns nonzero if <[x]> is an NaN, else 0.@*
+The isnormal macro returns nonzero if <[x]> has a normal value, else 0.
+
+PORTABILITY
+math.h macros are C99, POSIX.
+
+ieeefp.h funtions are outdated and should be avoided.
QUICKREF
isnan - pure