xref: /freebsd/lib/libc/gen/fpclassify.3 (revision 6137b5f7b8c183ee8806d79b3f1d8e5e3ddb3df3)
1.\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd January 26, 2005
26.Dt FPCLASSIFY 3
27.Os
28.Sh NAME
29.Nm fpclassify , isfinite , isinf , isnan , isnormal
30.Nd "classify a floating-point number"
31.Sh LIBRARY
32.Lb libm
33.Sh SYNOPSIS
34.In math.h
35.Ft int
36.Fn fpclassify "real-floating x"
37.Ft int
38.Fn isfinite "real-floating x"
39.Ft int
40.Fn isinf "real-floating x"
41.Ft int
42.Fn isnan "real-floating x"
43.Ft int
44.Fn isnormal "real-floating x"
45.Sh DESCRIPTION
46The
47.Fn fpclassify
48macro takes an argument of
49.Fa x
50and returns one of the following manifest constants.
51.Bl -tag -width ".Dv FP_SUBNORMAL"
52.It Dv FP_INFINITE
53Indicates that
54.Fa x
55is an infinite number.
56.It Dv FP_NAN
57Indicates that
58.Fa x
59is not a number (NaN).
60.It Dv FP_NORMAL
61Indicates that
62.Fa x
63is a normalized number.
64.It Dv FP_SUBNORMAL
65Indicates that
66.Fa x
67is a denormalized number.
68.It Dv FP_ZERO
69Indicates that
70.Fa x
71is zero (0 or \-0).
72.El
73.Pp
74The
75.Fn isfinite
76macro returns a non-zero value if and only if its argument has
77a finite (zero, subnormal, or normal) value.
78The
79.Fn isinf ,
80.Fn isnan ,
81and
82.Fn isnormal
83macros return non-zero if and only if
84.Fa x
85is an infinity, NaN,
86or a non-zero normalized number, respectively.
87.Pp
88The symbol
89.Fn isnanf
90is provided as an alias to
91.Fn isnan
92for compatibility, and its use is deprecated.
93Similarly,
94.Fn finite
95and
96.Fn finitef
97are deprecated versions of
98.Fn isfinite .
99.Sh SEE ALSO
100.Xr isgreater 3 ,
101.Xr math 3 ,
102.Xr signbit 3
103.Sh STANDARDS
104The
105.Fn fpclassify ,
106.Fn isfinite ,
107.Fn isinf ,
108.Fn isnan ,
109and
110.Fn isnormal
111macros conform to
112.St -isoC-99 .
113.Sh HISTORY
114The
115.Fn fpclassify ,
116.Fn isfinite ,
117.Fn isinf ,
118.Fn isnan ,
119and
120.Fn isnormal
121macros were added in
122.Fx 5.1 .
123.Bx 3
124introduced
125.Fn isinf
126and
127.Fn isnan
128functions, which accepted
129.Vt double
130arguments; these have been superseded by the macros
131described above.
132