]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/fpclassify.3
proc.5: Note kernel version for /proc/PID/smaps VmFlags "wf" flag
[thirdparty/man-pages.git] / man3 / fpclassify.3
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\"
3 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
4 .\" Distributed under GPL
5 .\" %%%LICENSE_END
6 .\"
7 .\" This was done with the help of the glibc manual.
8 .\"
9 .\" 2004-10-31, aeb, corrected
10 .TH FPCLASSIFY 3 2017-09-15 "" "Linux Programmer's Manual"
11 .SH NAME
12 fpclassify, isfinite, isnormal, isnan, isinf \- floating-point
13 classification macros
14 .SH SYNOPSIS
15 .nf
16 .B #include <math.h>
17 .PP
18 .BI "int fpclassify(" x );
19 .PP
20 .BI "int isfinite(" x );
21 .PP
22 .BI "int isnormal(" x );
23 .PP
24 .BI "int isnan(" x );
25 .PP
26 .BI "int isinf(" x );
27 .fi
28 .PP
29 Link with \fI\-lm\fP.
30 .PP
31 .in -4n
32 Feature Test Macro Requirements for glibc (see
33 .BR feature_test_macros (7)):
34 .in
35 .PP
36 .\" I haven't fully grokked the source to determine the FTM requirements;
37 .\" in part, the following has been tested by experiment.
38 .ad l
39 .BR fpclassify (),
40 .BR isfinite (),
41 .BR isnormal ():
42 .RS 4
43 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
44 .RE
45 .BR isnan ():
46 .RS 4
47 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
48 || _XOPEN_SOURCE
49 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
50 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
51 .RE
52 .BR isinf ():
53 .RS 4
54 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
55 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
56 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
57 .RE
58 .ad
59 .SH DESCRIPTION
60 Floating point numbers can have special values, such as
61 infinite or NaN.
62 With the macro
63 .BI fpclassify( x )
64 you can find out what type
65 .I x
66 is.
67 The macro takes any floating-point expression as argument.
68 The result is one of the following values:
69 .TP 14
70 .B FP_NAN
71 .I x
72 is "Not a Number".
73 .TP
74 .B FP_INFINITE
75 .I x
76 is either positive infinity or negative infinity.
77 .TP
78 .B FP_ZERO
79 .I x
80 is zero.
81 .TP
82 .B FP_SUBNORMAL
83 .I x
84 is too small to be represented in normalized format.
85 .TP
86 .B FP_NORMAL
87 if nothing of the above is correct then it must be a
88 normal floating-point number.
89 .PP
90 The other macros provide a short answer to some standard questions.
91 .TP 14
92 .BI isfinite( x )
93 returns a nonzero value if
94 .br
95 (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
96 .TP
97 .BI isnormal( x )
98 returns a nonzero value if
99 (fpclassify(x) == FP_NORMAL)
100 .TP
101 .BI isnan( x )
102 returns a nonzero value if
103 (fpclassify(x) == FP_NAN)
104 .TP
105 .BI isinf( x )
106 returns 1 if
107 .I x
108 is positive infinity, and \-1 if
109 .I x
110 is negative infinity.
111 .SH ATTRIBUTES
112 For an explanation of the terms used in this section, see
113 .BR attributes (7).
114 .ad l
115 .TS
116 allbox;
117 lbw28 lb lb
118 l l l.
119 Interface Attribute Value
120 T{
121 .BR fpclassify (),
122 .BR isfinite (),
123 .BR isnormal (),
124 .BR isnan (),
125 .BR isinf ()
126 T} Thread safety MT-Safe
127 .TE
128 .ad
129 .SH CONFORMING TO
130 POSIX.1-2001, POSIX.1-2008, C99.
131 .PP
132 For
133 .BR isinf (),
134 the standards merely say that the return value is nonzero
135 if and only if the argument has an infinite value.
136 .SH NOTES
137 In glibc 2.01 and earlier,
138 .BR isinf ()
139 returns a nonzero value (actually: 1) if
140 .I x
141 is positive infinity or negative infinity.
142 (This is all that C99 requires.)
143 .SH SEE ALSO
144 .BR finite (3),
145 .BR INFINITY (3),
146 .BR isgreater (3),
147 .BR signbit (3)