]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de) |
2 | .\" Distributed under GPL, 2002-07-27 Walter Harms | |
3 | .\" This was done with the help of the glibc manual. | |
4 | .\" | |
5 | .\" 2004-10-31, aeb, corrected | |
cc4615cc | 6 | .TH FPCLASSIFY 3 2007-07-26 "" "Linux Programmer's Manual" |
fea681da | 7 | .SH NAME |
2fd7b9d4 MK |
8 | fpclassify, isfinite, isnormal, isnan, isinf \- floating-point |
9 | classification macros | |
fea681da MK |
10 | .SH SYNOPSIS |
11 | .nf | |
12 | .B #include <math.h> | |
13 | .sp | |
14 | .BI "int fpclassify(" x ); | |
15 | .sp | |
16 | .BI "int isfinite(" x ); | |
17 | .sp | |
18 | .BI "int isnormal(" x ); | |
19 | .sp | |
20 | .BI "int isnan(" x ); | |
21 | .sp | |
22 | .BI "int isinf(" x ); | |
23 | .fi | |
462a7bad | 24 | .sp |
cc4615cc MK |
25 | Link with \fI\-lm\fP. |
26 | .sp | |
27 | .in -4n | |
28 | Feature Test Macro Requirements for glibc (see | |
29 | .BR feature_test_macros (7)): | |
30 | .in | |
31 | .sp | |
32 | .\" I haven't fully grokked the source to determine the FTM requirements; | |
33 | .\" in part, the following has been tested by experiment. | |
34 | .ad l | |
35 | .BR fpclassify (), | |
36 | .BR isfinite (), | |
37 | .BR isnormal (): | |
38 | _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or | |
39 | .I cc\ -std=c99 | |
40 | .br | |
41 | .BR isnan (): | |
42 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE; or | |
43 | .I cc\ -std=c99 | |
44 | .br | |
45 | .BR isinf (): | |
46 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or | |
47 | .I cc\ -std=c99 | |
48 | .ad b | |
fea681da MK |
49 | .SH DESCRIPTION |
50 | Floating point numbers can have special values, such as | |
1c44bd5b MK |
51 | infinite or NaN. |
52 | With the macro | |
c13182ef | 53 | .BI fpclassify( x ) |
fea681da MK |
54 | you can find out what type |
55 | .I x | |
1c44bd5b MK |
56 | is. |
57 | The macro takes any floating-point expression as argument. | |
c13182ef | 58 | The result is one of the following values: |
fea681da | 59 | .TP |
b20979f0 | 60 | .B FP_NAN |
fea681da MK |
61 | .I x |
62 | is "Not a Number". | |
63 | .TP | |
b20979f0 | 64 | .B FP_INFINITE |
fea681da MK |
65 | .I x |
66 | is either plus or minus infinity. | |
c13182ef | 67 | .TP |
b20979f0 | 68 | .B FP_ZERO |
fea681da MK |
69 | .I x |
70 | is zero. | |
71 | .TP | |
b20979f0 | 72 | .B FP_SUBNORMAL |
fea681da MK |
73 | .I x |
74 | is too small to be represented in normalized format. | |
75 | .TP | |
b20979f0 | 76 | .B FP_NORMAL |
6dff8403 | 77 | if nothing of the above is correct then it must be a |
fea681da MK |
78 | normal floating-point number. |
79 | .LP | |
80 | The other macros provide a short answer to some standard questions. | |
81 | .TP | |
82 | .BI isfinite( x ) | |
eba72288 | 83 | returns a non-zero value if |
fea681da MK |
84 | .br |
85 | (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE) | |
86 | .TP | |
87 | .BI isnormal( x ) | |
eba72288 | 88 | returns a non-zero value if |
fea681da MK |
89 | (fpclassify(x) == FP_NORMAL) |
90 | .TP | |
91 | .BI isnan( x ) | |
eba72288 | 92 | returns a non-zero value if |
fea681da MK |
93 | (fpclassify(x) == FP_NAN) |
94 | .TP | |
95 | .BI isinf( x ) | |
3243fedf MK |
96 | returns 1 if |
97 | .I x | |
98 | is positive infinity, and \-1 if | |
99 | .I x | |
100 | is negative infinity. | |
2b2581ee MK |
101 | .SH "CONFORMING TO" |
102 | C99 | |
19c98696 | 103 | .SH NOTES |
3243fedf | 104 | In glibc 2.01 and earlier, |
63aa9df0 | 105 | .BR isinf () |
eba72288 | 106 | returns a non-zero value (actually: 1) if |
3243fedf MK |
107 | .I x |
108 | is an infinity (positive or negative). | |
109 | (This is all that C99 requires.) | |
fea681da MK |
110 | .SH "SEE ALSO" |
111 | .BR finite (3), | |
112 | .BR INFINITY (3), | |
113 | .BR isgreater (3) |