2004-11-03 13:51:07 +00:00
|
|
|
.\" 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
|
2004-11-16 11:01:14 +00:00
|
|
|
.sp
|
2005-07-06 07:41:37 +00:00
|
|
|
Compile with \-std=c99; link with \-lm.
|
2004-11-03 13:51:07 +00:00
|
|
|
.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.
|
2006-04-21 19:07:17 +00:00
|
|
|
The result is one of the following values:
|
2004-11-03 13:51:07 +00:00
|
|
|
.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
|
2006-04-21 19:01:43 +00:00
|
|
|
if nothing of the above is correct then it must be a
|
2004-11-03 13:51:07 +00:00
|
|
|
normal floating-point number.
|
|
|
|
.LP
|
|
|
|
The other macros provide a short answer to some standard questions.
|
|
|
|
.TP
|
|
|
|
.BI isfinite( x )
|
2005-06-15 13:32:34 +00:00
|
|
|
returns a non-zero value if
|
2004-11-03 13:51:07 +00:00
|
|
|
.br
|
|
|
|
(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
|
|
|
|
.TP
|
|
|
|
.BI isnormal( x )
|
2005-06-15 13:32:34 +00:00
|
|
|
returns a non-zero value if
|
2004-11-03 13:51:07 +00:00
|
|
|
(fpclassify(x) == FP_NORMAL)
|
|
|
|
.TP
|
|
|
|
.BI isnan( x )
|
2005-06-15 13:32:34 +00:00
|
|
|
returns a non-zero value if
|
2004-11-03 13:51:07 +00:00
|
|
|
(fpclassify(x) == FP_NAN)
|
|
|
|
.TP
|
|
|
|
.BI isinf( x )
|
2005-06-24 12:38:56 +00:00
|
|
|
returns 1 if
|
|
|
|
.I x
|
|
|
|
is positive infinity, and \-1 if
|
|
|
|
.I x
|
|
|
|
is negative infinity.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTE
|
2005-06-24 12:38:56 +00:00
|
|
|
In glibc 2.01 and earlier,
|
2005-10-19 07:07:02 +00:00
|
|
|
.BR isinf ()
|
2005-06-24 12:38:56 +00:00
|
|
|
returns a non-zero value (actually: 1) if
|
|
|
|
.I x
|
|
|
|
is an infinity (positive or negative).
|
|
|
|
(This is all that C99 requires.)
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
C99
|
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR finite (3),
|
|
|
|
.BR INFINITY (3),
|
|
|
|
.BR isgreater (3)
|
|
|
|
|