| 1 |
'\" t |
| 2 |
.\" Copyright 2002, Walter Harms <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: GPL-1.0-or-later |
| 6 |
.\" |
| 7 |
.TH fpclassify 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
fpclassify, isfinite, isnormal, isnan, isinf \- floating-point |
| 10 |
classification macros |
| 11 |
.SH LIBRARY |
| 12 |
Math library |
| 13 |
.RI ( libm ,\~ \-lm ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <math.h> |
| 17 |
.P |
| 18 |
.BI "int fpclassify(" x ); |
| 19 |
.BI "int isfinite(" x ); |
| 20 |
.BI "int isnormal(" x ); |
| 21 |
.BI "int isnan(" x ); |
| 22 |
.BI "int isinf(" x ); |
| 23 |
.fi |
| 24 |
.P |
| 25 |
.RS -4 |
| 26 |
Feature Test Macro Requirements for glibc (see |
| 27 |
.BR feature_test_macros (7)): |
| 28 |
.RE |
| 29 |
.P |
| 30 |
.\" I haven't fully grokked the source to determine the FTM requirements; |
| 31 |
.\" in part, the following has been tested by experiment. |
| 32 |
.BR fpclassify (), |
| 33 |
.BR isfinite (), |
| 34 |
.BR isnormal (): |
| 35 |
.nf |
| 36 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 37 |
.fi |
| 38 |
.P |
| 39 |
.BR isnan (): |
| 40 |
.nf |
| 41 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 42 |
|| _XOPEN_SOURCE |
| 43 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 44 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 45 |
.fi |
| 46 |
.P |
| 47 |
.BR isinf (): |
| 48 |
.nf |
| 49 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 50 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 51 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 52 |
.fi |
| 53 |
.SH DESCRIPTION |
| 54 |
Floating point numbers can have special values, such as |
| 55 |
infinite or NaN. |
| 56 |
With the macro |
| 57 |
.BI fpclassify( x ) |
| 58 |
you can find out what type |
| 59 |
.I x |
| 60 |
is. |
| 61 |
The macro takes any floating-point expression as argument. |
| 62 |
The result is one of the following values: |
| 63 |
.TP 14 |
| 64 |
.B FP_NAN |
| 65 |
.I x |
| 66 |
is "Not a Number". |
| 67 |
.TP |
| 68 |
.B FP_INFINITE |
| 69 |
.I x |
| 70 |
is either positive infinity or negative infinity. |
| 71 |
.TP |
| 72 |
.B FP_ZERO |
| 73 |
.I x |
| 74 |
is zero. |
| 75 |
.TP |
| 76 |
.B FP_SUBNORMAL |
| 77 |
.I x |
| 78 |
is too small to be represented in normalized format. |
| 79 |
.TP |
| 80 |
.B FP_NORMAL |
| 81 |
if nothing of the above is correct then it must be a |
| 82 |
normal floating-point number. |
| 83 |
.P |
| 84 |
The other macros provide a short answer to some standard questions. |
| 85 |
.TP 14 |
| 86 |
.BI isfinite( x ) |
| 87 |
returns a nonzero value if |
| 88 |
.br |
| 89 |
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE) |
| 90 |
.TP |
| 91 |
.BI isnormal( x ) |
| 92 |
returns a nonzero value if |
| 93 |
(fpclassify(x) == FP_NORMAL) |
| 94 |
.TP |
| 95 |
.BI isnan( x ) |
| 96 |
returns a nonzero value if |
| 97 |
(fpclassify(x) == FP_NAN) |
| 98 |
.TP |
| 99 |
.BI isinf( x ) |
| 100 |
returns 1 if |
| 101 |
.I x |
| 102 |
is positive infinity, and \-1 if |
| 103 |
.I x |
| 104 |
is negative infinity. |
| 105 |
.SH ATTRIBUTES |
| 106 |
For an explanation of the terms used in this section, see |
| 107 |
.BR attributes (7). |
| 108 |
.TS |
| 109 |
allbox; |
| 110 |
lbx lb lb |
| 111 |
l l l. |
| 112 |
Interface Attribute Value |
| 113 |
T{ |
| 114 |
.na |
| 115 |
.nh |
| 116 |
.BR fpclassify (), |
| 117 |
.BR isfinite (), |
| 118 |
.BR isnormal (), |
| 119 |
.BR isnan (), |
| 120 |
.BR isinf () |
| 121 |
T} Thread safety MT-Safe |
| 122 |
.TE |
| 123 |
.SH STANDARDS |
| 124 |
C11, POSIX.1-2008. |
| 125 |
.SH HISTORY |
| 126 |
POSIX.1-2001, C99. |
| 127 |
.P |
| 128 |
In glibc 2.01 and earlier, |
| 129 |
.BR isinf () |
| 130 |
returns a nonzero value (actually: 1) if |
| 131 |
.I x |
| 132 |
is positive infinity or negative infinity. |
| 133 |
(This is all that C99 requires.) |
| 134 |
.SH NOTES |
| 135 |
For |
| 136 |
.BR isinf (), |
| 137 |
the standards merely say that the return value is nonzero |
| 138 |
if and only if the argument has an infinite value. |
| 139 |
.SH SEE ALSO |
| 140 |
.BR finite (3), |
| 141 |
.BR INFINITY (3), |
| 142 |
.BR isgreater (3), |
| 143 |
.BR signbit (3) |