mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / fpclassify.3
blobba23cf2468436ae05a3b2e71f368f2d91dcf08fb
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  2021-03-22 "" "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 .BI "int isfinite(" x );
20 .BI "int isnormal(" x );
21 .BI "int isnan(" x );
22 .BI "int isinf(" x );
23 .fi
24 .PP
25 Link with \fI\-lm\fP.
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)
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
113 allbox;
114 lbx lb lb
115 l l l.
116 Interface       Attribute       Value
118 .BR fpclassify (),
119 .BR isfinite (),
120 .BR isnormal (),
121 .BR isnan (),
122 .BR isinf ()
123 T}      Thread safety   MT-Safe
127 .sp 1
128 .SH CONFORMING TO
129 POSIX.1-2001, POSIX.1-2008, C99.
132 .BR isinf (),
133 the standards merely say that the return value is nonzero
134 if and only if the argument has an infinite value.
135 .SH NOTES
136 In glibc 2.01 and earlier,
137 .BR isinf ()
138 returns a nonzero value (actually: 1) if
139 .I x
140 is positive infinity or negative infinity.
141 (This is all that C99 requires.)
142 .SH SEE ALSO
143 .BR finite (3),
144 .BR INFINITY (3),
145 .BR isgreater (3),
146 .BR signbit (3)