Name
fpclassify, isfinite, isinf, isnan, isnormal
- floating-point classification macros
Library
libm.lib
Synopsis
|
int
fpclassify (real-floating x);
|
|
int
isfinite (real-floating x);
|
|
int
isinf (real-floating x);
|
|
int
isnan (real-floating x);
|
|
int
isnormal (real-floating x);
|
Detailed description
The
fpclassify
macro takes an argument of
x
and returns one of the following manifest constants.
FP_INFINITE
|
Indicates that
x
is an infinite number.
|
FP_NAN
|
Indicates that
x
is not a number (NaN).
|
FP_NORMAL
|
Indicates that
x
is a normalized number.
|
FP_SUBNORMAL
|
|
Indicates that
x
is a denormalized number.
|
FP_ZERO
|
Indicates that
x
is zero (0 or -0).
|
|
The
isfinite
macro returns a non-zero value if and only if its argument has
a finite (zero, subnormal, or normal) value.
The
isinf,
isnan,
and
isnormal
macros return non-zero if and only if
x
is an infinity, NaN,
or a non-zero normalized number, respectively.
The symbol
isnanf
is provided as an alias to
isnan
for compatibility, and its use is deprecated.
Examples
#include <math.h>
void main()
{
double x1 = 6.5, x2 = 2.25;
int y;
y = fpclassify( x1);
/* Use the Predefine Macro to
determine the Return Values
interpretation
*/
switch( y ){
case FP_INFINITE: printf("%f is a Infinite Value\n", x1);break;
case FP_NAN: printf("%f is a NAN Value\n", x1);break;
case FP_NORMAL: printf("%f is a Normalized Floating point Value\n", x1);break;
case FP_SUBNORMAL:printf("%f is a Subnormalized Floating point Number\n", x1);break;
case FP_ZERO: printf("%f is a Zero\n", x1);break;
case default: printf("%f is a Invalid Input", x1);break;
}
y = isfinite( x1 );
printf( "isfinite(%f) = %d\n", x1, y );
y = isinf( x1);
printf( "isinf(%f) = %d\n", x1 y );
y = isnan( x1);
printf( "isnan(%f) = %f\n", x1, y );
y = isnormal( x1);
printf( isnormal(%f) = %f\n", x1, y );
}
Output
6.5 is a Normalized Floating point Value
isfinite(6.5) = 1
isinf(6.5) = 1
isnan(6.5) = 0
isnormal(6.5) = 1
See also
math,
signbit
Feedback
For additional information or queries on this page send feedback
© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user. |
|