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():
27 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
28 _POSIX_C_SOURCE >= 200112L;
29 or cc -std=c99
30 isnan():
31 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
32 _POSIX_C_SOURCE >= 200112L;
33 or cc -std=c99
34 isinf():
35 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
36 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
37 or cc -std=c99
38
40 Floating point numbers can have special values, such as infinite or
41 NaN. With the macro fpclassify(x) you can find out what type x is.
42 The macro takes any floating-point expression as argument. The result
43 is one of the following values:
44
45 FP_NAN x is "Not a Number".
46
47 FP_INFINITE x is either positive infinity or negative infinity.
48
49 FP_ZERO x is zero.
50
51 FP_SUBNORMAL x is too small to be represented in normalized format.
52
53 FP_NORMAL if nothing of the above is correct then it must be a nor‐
54 mal floating-point number.
55
56 The other macros provide a short answer to some standard questions.
57
58 isfinite(x) returns a nonzero value if
59 (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
60
61 isnormal(x) returns a nonzero value if (fpclassify(x) == FP_NORMAL)
62
63 isnan(x) returns a nonzero value if (fpclassify(x) == FP_NAN)
64
65 isinf(x) returns 1 if x is positive infinity, and -1 if x is nega‐
66 tive infinity.
67
69 C99, POSIX.1.
70
71 For isinf(), the standards merely say that the return value is nonzero
72 if and only if the argument has an infinite value.
73
75 In glibc 2.01 and earlier, isinf() returns a nonzero value (actually:
76 1) if x is positive infinity or negative infinity. (This is all that
77 C99 requires.)
78
80 finite(3), INFINITY(3), isgreater(3), signbit(3)
81
83 This page is part of release 3.53 of the Linux man-pages project. A
84 description of the project, and information about reporting bugs, can
85 be found at http://www.kernel.org/doc/man-pages/.
86
87
88
89 2010-09-20 FPCLASSIFY(3)