1FPCLASSIFY(3) Linux Programmer's Manual FPCLASSIFY(3)
2
3
4
6 fpclassify, isfinite, isnormal, isnan - floating-point classification
7 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 Compile with -std=c99; link with -lm.
23
25 Floating point numbers can have special values, such as infinite or
26 NaN. With the macro fpclassify(x) you can find out what type x is. The
27 macro takes any floating-point expression as argument. The result is
28 one of the following values:
29
30 FP_NAN x is "Not a Number".
31
32 FP_INFINITE
33 x is either plus or minus infinity.
34
35 FP_ZERO
36 x is zero.
37
38 FP_SUBNORMAL
39 x is too small to be represented in normalized format.
40
41 FP_NORMAL
42 if nothing of the above is correct then it must be a normal
43 floating-point number.
44
45 The other macros provide a short answer to some standard questions.
46
47 isfinite(x)
48 returns a non-zero value if
49 (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
50
51 isnormal(x)
52 returns a non-zero value if (fpclassify(x) == FP_NORMAL)
53
54 isnan(x)
55 returns a non-zero value if (fpclassify(x) == FP_NAN)
56
57 isinf(x)
58 returns 1 if x is positive infinity, and -1 if x is negative
59 infinity.
60
62 In glibc 2.01 and earlier, isinf() returns a non-zero value (actually:
63 1) if x is an infinity (positive or negative). (This is all that C99
64 requires.)
65
67 C99
68
70 finite(3), INFINITY(3), isgreater(3)
71
72
73
74
75 2004-10-31 FPCLASSIFY(3)