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