summaryrefslogtreecommitdiff
path: root/man3/fpclassify.3
blob: a1f87cccee8f27ffae069fcf4d59d44ef59375a4 (plain)
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
.\" 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  2004-10-31 "" "Linux Programmer's Manual"
.SH NAME
fpclassify, isfinite, isnormal, isnan \- 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
Compile with \-std=c99; link with \-lm.
.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
FP_NAN
.I x
is "Not a Number".
.TP
FP_INFINITE
.I x
is either plus or minus infinity.
.TP
FP_ZERO
.I x
is zero.
.TP
FP_SUBNORMAL
.I x
is too small to be represented in normalized format.
.TP
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
.BI isfinite( x )
returns a non-zero value if
.br
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
.TP
.BI isnormal( x )
returns a non-zero value if
(fpclassify(x) == FP_NORMAL)
.TP
.BI isnan( x )
returns a non-zero 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 NOTE
In glibc 2.01 and earlier,
.BR isinf ()
returns a non-zero value (actually: 1) if
.I x
is an infinity (positive or negative).
(This is all that C99 requires.)
.SH "CONFORMING TO"
C99
.SH "SEE ALSO"
.BR finite (3),
.BR INFINITY (3),
.BR isgreater (3)