]>
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 | |
d41a0a77 | 6 | .TH FPCLASSIFY 3 2008-08-07 "" "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: |
5840de13 | 59 | .TP 14 |
b20979f0 | 60 | .B FP_NAN |
fea681da MK |
61 | .I x |
62 | is "Not a Number". | |
63 | .TP | |
b20979f0 | 64 | .B FP_INFINITE |
fea681da | 65 | .I x |
14a05a52 | 66 | is either positive infinity or negative 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. | |
5840de13 | 81 | .TP 14 |
fea681da | 82 | .BI isfinite( x ) |
c7094399 | 83 | returns a nonzero value if |
fea681da MK |
84 | .br |
85 | (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE) | |
86 | .TP | |
87 | .BI isnormal( x ) | |
c7094399 | 88 | returns a nonzero value if |
fea681da MK |
89 | (fpclassify(x) == FP_NORMAL) |
90 | .TP | |
91 | .BI isnan( x ) | |
c7094399 | 92 | returns a nonzero 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 | 101 | .SH "CONFORMING TO" |
9ebd8588 | 102 | C99, POSIX.1. |
d41a0a77 MK |
103 | |
104 | For | |
105 | .BR isinf (), | |
c7094399 | 106 | the standards merely say that the return value is nonzero |
d41a0a77 | 107 | if and only if the argument has an infinite value. |
19c98696 | 108 | .SH NOTES |
3243fedf | 109 | In glibc 2.01 and earlier, |
63aa9df0 | 110 | .BR isinf () |
c7094399 | 111 | returns a nonzero value (actually: 1) if |
3243fedf | 112 | .I x |
14a05a52 | 113 | is positive infinity or negative infinity. |
3243fedf | 114 | (This is all that C99 requires.) |
fea681da MK |
115 | .SH "SEE ALSO" |
116 | .BR finite (3), | |
117 | .BR INFINITY (3), | |
61f56d72 MK |
118 | .BR isgreater (3), |
119 | .BR signbit (3) |