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