Classification of Floating-Point Numbers
ANSI C99 defines five categories of floating-point numbers, listed in Table 1-28. A symbolic constant for each category is defined in the header file math.h .
|
Macro name |
Category |
FP_ZERO |
Floating-point numbers with the value 0 |
FP_NORMAL |
Floating-point numbers in normalized representation |
FP_SUBNORMAL[1] |
Floating-point numbers in subnormal representation |
FP_INFINITE |
Floating-point numbers that represent an infinite value |
FP_NAN |
Not a Number (NAN): bit patterns that do not represent a valid floating-point number |
[1] Tiny numbers may be represented in subnormal notation. | |
The macros in Table 1-29 can be used to classify a
real floating-point number x with respect
to the categories in Table 1-28 without causing an
error condition.
|
Macro |
Result |
fpclassify(
|
Returns one of the constants described in Table 1-28 to indicate the category to which
|
isfinite(
|
Returns “true” (i. e., a value
other than |
isinf(
|
Returns “true” if
|
isnormal(
|
Returns “true” if the value of
|
isnan(
|
Returns “true” if
|
signbit(
|
Returns “true” if
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access