man-pages/man3/fpclassify.3.html
2021-03-31 01:06:50 +01:00

241 lines
5.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of FPCLASSIFY</TITLE>
</HEAD><BODY>
<H1>FPCLASSIFY</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
fpclassify, isfinite, isnormal, isnan, isinf - floating-point
classification macros
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/math.h">math.h</A>&gt;</B>
<B>int fpclassify(</B><I>x</I><B>);</B>
<B>int isfinite(</B><I>x</I><B>);</B>
<B>int isnormal(</B><I>x</I><B>);</B>
<B>int isnan(</B><I>x</I><B>);</B>
<B>int isinf(</B><I>x</I><B>);</B>
</PRE>
<P>
Link with <I>-lm</I>.
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>fpclassify</B>(),
<B>isfinite</B>(),
<B>isnormal</B>():
<DL COMPACT><DT id="1"><DD>
_ISOC99_SOURCE || _POSIX_C_SOURCE&nbsp;&gt;=&nbsp;200112L
</DL>
<B>isnan</B>():
<DL COMPACT><DT id="2"><DD>
_ISOC99_SOURCE || _POSIX_C_SOURCE&nbsp;&gt;=&nbsp;200112L
<BR>&nbsp;&nbsp;&nbsp;&nbsp;||&nbsp;_XOPEN_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;||&nbsp;/*&nbsp;Since&nbsp;glibc&nbsp;2.19:&nbsp;*/&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;||&nbsp;/*&nbsp;Glibc&nbsp;versions&nbsp;&lt;=&nbsp;2.19:&nbsp;*/&nbsp;_BSD_SOURCE&nbsp;||&nbsp;_SVID_SOURCE
</DL>
<B>isinf</B>():
<DL COMPACT><DT id="3"><DD>
_ISOC99_SOURCE || _POSIX_C_SOURCE&nbsp;&gt;=&nbsp;200112L
<BR>&nbsp;&nbsp;&nbsp;&nbsp;||&nbsp;/*&nbsp;Since&nbsp;glibc&nbsp;2.19:&nbsp;*/&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;||&nbsp;/*&nbsp;Glibc&nbsp;versions&nbsp;&lt;=&nbsp;2.19:&nbsp;*/&nbsp;_BSD_SOURCE&nbsp;||&nbsp;_SVID_SOURCE
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Floating point numbers can have special values, such as
infinite or NaN.
With the macro
<B>fpclassify(</B><I>x</I><B>)</B>
you can find out what type
<I>x</I>
is.
The macro takes any floating-point expression as argument.
The result is one of the following values:
<DL COMPACT>
<DT id="4"><B>FP_NAN</B>
<DD>
<I>x</I>
is &quot;Not a Number&quot;.
<DT id="5"><B>FP_INFINITE</B>
<DD>
<I>x</I>
is either positive infinity or negative infinity.
<DT id="6"><B>FP_ZERO</B>
<DD>
<I>x</I>
is zero.
<DT id="7"><B>FP_SUBNORMAL</B>
<DD>
<I>x</I>
is too small to be represented in normalized format.
<DT id="8"><B>FP_NORMAL</B>
<DD>
if nothing of the above is correct then it must be a
normal floating-point number.
</DL>
<P>
The other macros provide a short answer to some standard questions.
<DL COMPACT>
<DT id="9"><B>isfinite(</B><I>x</I><B>)</B>
<DD>
returns a nonzero value if
<BR>
(fpclassify(x) != FP_NAN &amp;&amp; fpclassify(x) != FP_INFINITE)
<DT id="10"><B>isnormal(</B><I>x</I><B>)</B>
<DD>
returns a nonzero value if
(fpclassify(x) == FP_NORMAL)
<DT id="11"><B>isnan(</B><I>x</I><B>)</B>
<DD>
returns a nonzero value if
(fpclassify(x) == FP_NAN)
<DT id="12"><B>isinf(</B><I>x</I><B>)</B>
<DD>
returns 1 if
<I>x</I>
is positive infinity, and -1 if
<I>x</I>
is negative infinity.
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>fpclassify</B>(),
<B>isfinite</B>(),
<B>isnormal</B>(),
<B>isnan</B>(),
<B>isinf</B>()
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
</TABLE>
<A NAME="lbAF">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008, C99.
<P>
For
<B>isinf</B>(),
the standards merely say that the return value is nonzero
if and only if the argument has an infinite value.
<A NAME="lbAG">&nbsp;</A>
<H2>NOTES</H2>
In glibc 2.01 and earlier,
<B>isinf</B>()
returns a nonzero value (actually: 1) if
<I>x</I>
is positive infinity or negative infinity.
(This is all that C99 requires.)
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+finite">finite</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+INFINITY">INFINITY</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+isgreater">isgreater</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+signbit">signbit</A></B>(3)
<A NAME="lbAI">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="13"><A HREF="#lbAB">NAME</A><DD>
<DT id="14"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="15"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="16"><A HREF="#lbAE">ATTRIBUTES</A><DD>
<DT id="17"><A HREF="#lbAF">CONFORMING TO</A><DD>
<DT id="18"><A HREF="#lbAG">NOTES</A><DD>
<DT id="19"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="20"><A HREF="#lbAI">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:43 GMT, March 31, 2021
</BODY>
</HTML>