Blame man3/fpclassify.3

Packit 7cfc04
.\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
Packit 7cfc04
.\" Distributed under GPL
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" This was done with the help of the glibc manual.
Packit 7cfc04
.\"
Packit 7cfc04
.\" 2004-10-31, aeb, corrected
Packit 7cfc04
.TH FPCLASSIFY 3  2017-09-15 "" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
fpclassify, isfinite, isnormal, isnan, isinf \- floating-point
Packit 7cfc04
classification macros
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <math.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int fpclassify(" x );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int isfinite(" x );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int isnormal(" x );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int isnan(" x );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int isinf(" x );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
Link with \fI\-lm\fP.
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.\" I haven't fully grokked the source to determine the FTM requirements;
Packit 7cfc04
.\" in part, the following has been tested by experiment.
Packit 7cfc04
.ad l
Packit 7cfc04
.BR fpclassify (),
Packit 7cfc04
.BR isfinite (),
Packit 7cfc04
.BR isnormal ():
Packit 7cfc04
.RS 4
Packit 7cfc04
_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
Packit 7cfc04
.RE
Packit 7cfc04
.BR isnan ():
Packit 7cfc04
.RS 4
Packit 7cfc04
_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
Packit 7cfc04
    || _XOPEN_SOURCE
Packit 7cfc04
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.BR isinf ():
Packit 7cfc04
.RS 4
Packit 7cfc04
_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
Packit 7cfc04
    || /* Since glibc 2.19: */ _DEFAULT_SOURCE
Packit 7cfc04
    || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.ad
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
Floating point numbers can have special values, such as
Packit 7cfc04
infinite or NaN.
Packit 7cfc04
With the macro
Packit 7cfc04
.BI fpclassify( x )
Packit 7cfc04
you can find out what type
Packit 7cfc04
.I x
Packit 7cfc04
is.
Packit 7cfc04
The macro takes any floating-point expression as argument.
Packit 7cfc04
The result is one of the following values:
Packit 7cfc04
.TP 14
Packit 7cfc04
.B FP_NAN
Packit 7cfc04
.I x
Packit 7cfc04
is "Not a Number".
Packit 7cfc04
.TP
Packit 7cfc04
.B FP_INFINITE
Packit 7cfc04
.I x
Packit 7cfc04
is either positive infinity or negative infinity.
Packit 7cfc04
.TP
Packit 7cfc04
.B FP_ZERO
Packit 7cfc04
.I x
Packit 7cfc04
is zero.
Packit 7cfc04
.TP
Packit 7cfc04
.B FP_SUBNORMAL
Packit 7cfc04
.I x
Packit 7cfc04
is too small to be represented in normalized format.
Packit 7cfc04
.TP
Packit 7cfc04
.B FP_NORMAL
Packit 7cfc04
if nothing of the above is correct then it must be a
Packit 7cfc04
normal floating-point number.
Packit 7cfc04
.PP
Packit 7cfc04
The other macros provide a short answer to some standard questions.
Packit 7cfc04
.TP 14
Packit 7cfc04
.BI isfinite( x )
Packit 7cfc04
returns a nonzero value if
Packit 7cfc04
.br
Packit 7cfc04
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
Packit 7cfc04
.TP
Packit 7cfc04
.BI isnormal( x )
Packit 7cfc04
returns a nonzero value if
Packit 7cfc04
(fpclassify(x) == FP_NORMAL)
Packit 7cfc04
.TP
Packit 7cfc04
.BI isnan( x )
Packit 7cfc04
returns a nonzero value if
Packit 7cfc04
(fpclassify(x) == FP_NAN)
Packit 7cfc04
.TP
Packit 7cfc04
.BI isinf( x )
Packit 7cfc04
returns 1 if
Packit 7cfc04
.I x
Packit 7cfc04
is positive infinity, and \-1 if
Packit 7cfc04
.I x
Packit 7cfc04
is negative infinity.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.ad l
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lbw28 lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR fpclassify (),
Packit 7cfc04
.BR isfinite (),
Packit 7cfc04
.BR isnormal (),
Packit 7cfc04
.BR isnan (),
Packit 7cfc04
.BR isinf ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.ad
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008, C99.
Packit 7cfc04
.PP
Packit 7cfc04
For
Packit 7cfc04
.BR isinf (),
Packit 7cfc04
the standards merely say that the return value is nonzero
Packit 7cfc04
if and only if the argument has an infinite value.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
In glibc 2.01 and earlier,
Packit 7cfc04
.BR isinf ()
Packit 7cfc04
returns a nonzero value (actually: 1) if
Packit 7cfc04
.I x
Packit 7cfc04
is positive infinity or negative infinity.
Packit 7cfc04
(This is all that C99 requires.)
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR finite (3),
Packit 7cfc04
.BR INFINITY (3),
Packit 7cfc04
.BR isgreater (3),
Packit 7cfc04
.BR signbit (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.