1FPCLASSIFY(3) Linux Programmer's Manual FPCLASSIFY(3)
2
3
4
6 fpclassify, isfinite, isnormal, isnan, isinf - floating-point classifi‐
7 cation macros
8
10 #include <math.h>
11
12 int fpclassify(x);
13
14 int isfinite(x);
15
16 int isnormal(x);
17
18 int isnan(x);
19
20 int isinf(x);
21
22 Link with -lm.
23
24 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
25
26 fpclassify(), isfinite(), isnormal(): _XOPEN_SOURCE >= 600 ||
27 _ISOC99_SOURCE; or cc -std=c99
28 isnan(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE ||
29 _ISOC99_SOURCE; or cc -std=c99
30 isinf(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
31 _ISOC99_SOURCE; or cc -std=c99
32
34 Floating point numbers can have special values, such as infinite or
35 NaN. With the macro fpclassify(x) you can find out what type x is.
36 The macro takes any floating-point expression as argument. The result
37 is one of the following values:
38
39 FP_NAN x is "Not a Number".
40
41 FP_INFINITE x is either positive infinity or negative infinity.
42
43 FP_ZERO x is zero.
44
45 FP_SUBNORMAL x is too small to be represented in normalized format.
46
47 FP_NORMAL if nothing of the above is correct then it must be a nor‐
48 mal floating-point number.
49
50 The other macros provide a short answer to some standard questions.
51
52 isfinite(x) returns a non-zero value if
53 (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
54
55 isnormal(x) returns a non-zero value if (fpclassify(x) == FP_NORMAL)
56
57 isnan(x) returns a non-zero value if (fpclassify(x) == FP_NAN)
58
59 isinf(x) returns 1 if x is positive infinity, and -1 if x is nega‐
60 tive infinity.
61
63 C99, POSIX.1.
64
65 For isinf(), the standards merely say that the return value is non-zero
66 if and only if the argument has an infinite value.
67
69 In glibc 2.01 and earlier, isinf() returns a non-zero value (actually:
70 1) if x is positive infinity or negative infinity. (This is all that
71 C99 requires.)
72
74 finite(3), INFINITY(3), isgreater(3), signbit(3)
75
77 This page is part of release 3.22 of the Linux man-pages project. A
78 description of the project, and information about reporting bugs, can
79 be found at http://www.kernel.org/doc/man-pages/.
80
81
82
83 2008-08-07 FPCLASSIFY(3)