File: fpclassify.3

package info (click to toggle)
manpages 3.44-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 12,880 kB
  • sloc: sh: 404; perl: 166; makefile: 87; lisp: 22
file content (140 lines) | stat: -rw-r--r-- 2,910 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
.\" Distributed under GPL, 2002-07-27 Walter Harms
.\" This was done with the help of the glibc manual.
.\"
.\" 2004-10-31, aeb, corrected
.TH FPCLASSIFY 3  2010-09-20 "" "Linux Programmer's Manual"
.SH NAME
fpclassify, isfinite, isnormal, isnan, isinf \- floating-point
classification macros
.SH SYNOPSIS
.nf
.B #include <math.h>
.sp
.BI "int fpclassify(" x );
.sp
.BI "int isfinite(" x );
.sp
.BI "int isnormal(" x );
.sp
.BI "int isnan(" x );
.sp
.BI "int isinf(" x );
.fi
.sp
Link with \fI\-lm\fP.
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.sp
.\" I haven't fully grokked the source to determine the FTM requirements;
.\" in part, the following has been tested by experiment.
.ad l
.BR fpclassify (),
.BR isfinite (),
.BR isnormal ():
.RS 4
_XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
_POSIX_C_SOURCE\ >=\ 200112L;
.br
or
.I cc\ -std=c99
.RE
.BR isnan ():
.RS 4
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
_POSIX_C_SOURCE\ >=\ 200112L;
.br
or
.I cc\ -std=c99
.RE
.BR isinf ():
.RS 4
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
_POSIX_C_SOURCE\ >=\ 200112L;
.br
or
.I cc\ -std=c99
.RE
.ad
.SH DESCRIPTION
Floating point numbers can have special values, such as
infinite or NaN.
With the macro
.BI fpclassify( x )
you can find out what type
.I x
is.
The macro takes any floating-point expression as argument.
The result is one of the following values:
.TP 14
.B FP_NAN
.I x
is "Not a Number".
.TP
.B FP_INFINITE
.I x
is either positive infinity or negative infinity.
.TP
.B FP_ZERO
.I x
is zero.
.TP
.B FP_SUBNORMAL
.I x
is too small to be represented in normalized format.
.TP
.B FP_NORMAL
if nothing of the above is correct then it must be a
normal floating-point number.
.LP
The other macros provide a short answer to some standard questions.
.TP 14
.BI isfinite( x )
returns a nonzero value if
.br
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
.TP
.BI isnormal( x )
returns a nonzero value if
(fpclassify(x) == FP_NORMAL)
.TP
.BI isnan( x )
returns a nonzero value if
(fpclassify(x) == FP_NAN)
.TP
.BI isinf( x )
returns 1 if
.I x
is positive infinity, and \-1 if
.I x
is negative infinity.
.SH "CONFORMING TO"
C99, POSIX.1.

For
.BR isinf (),
the standards merely say that the return value is nonzero
if and only if the argument has an infinite value.
.SH NOTES
In glibc 2.01 and earlier,
.BR isinf ()
returns a nonzero value (actually: 1) if
.I x
is positive infinity or negative infinity.
(This is all that C99 requires.)
.SH "SEE ALSO"
.BR finite (3),
.BR INFINITY (3),
.BR isgreater (3),
.BR signbit (3)
.SH COLOPHON
This page is part of release 3.44 of the Linux
.I man-pages
project.
A description of the project,
and information about reporting bugs,
can be found at
http://www.kernel.org/doc/man-pages/.