|
|
/* @(#)s_isnan.c 5.1 93/09/24 */
|
/* @(#)s_isnan.c 5.1 93/09/24 */
|
/*
|
/*
|
* ====================================================
|
* ====================================================
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
*
|
*
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
* software is freely granted, provided that this notice
|
* software is freely granted, provided that this notice
|
* is preserved.
|
* is preserved.
|
* ====================================================
|
* ====================================================
|
*/
|
*/
|
|
|
/*
|
/*
|
FUNCTION
|
FUNCTION
|
<<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test for exceptional numbers
|
<<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test for exceptional numbers
|
|
|
INDEX
|
INDEX
|
isnan
|
isnan
|
INDEX
|
INDEX
|
isinf
|
isinf
|
INDEX
|
INDEX
|
finite
|
finite
|
|
|
INDEX
|
INDEX
|
isnanf
|
isnanf
|
INDEX
|
INDEX
|
isinff
|
isinff
|
INDEX
|
INDEX
|
finitef
|
finitef
|
|
|
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
#include <ieeefp.h>
|
#include <ieeefp.h>
|
int isnan(double <[arg]>);
|
int isnan(double <[arg]>);
|
int isinf(double <[arg]>);
|
int isinf(double <[arg]>);
|
int finite(double <[arg]>);
|
int finite(double <[arg]>);
|
int isnanf(float <[arg]>);
|
int isnanf(float <[arg]>);
|
int isinff(float <[arg]>);
|
int isinff(float <[arg]>);
|
int finitef(float <[arg]>);
|
int finitef(float <[arg]>);
|
|
|
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
#include <ieeefp.h>
|
#include <ieeefp.h>
|
int isnan(<[arg]>)
|
int isnan(<[arg]>)
|
double <[arg]>;
|
double <[arg]>;
|
int isinf(<[arg]>)
|
int isinf(<[arg]>)
|
double <[arg]>;
|
double <[arg]>;
|
int finite(<[arg]>);
|
int finite(<[arg]>);
|
double <[arg]>;
|
double <[arg]>;
|
int isnanf(<[arg]>);
|
int isnanf(<[arg]>);
|
float <[arg]>;
|
float <[arg]>;
|
int isinff(<[arg]>);
|
int isinff(<[arg]>);
|
float <[arg]>;
|
float <[arg]>;
|
int finitef(<[arg]>);
|
int finitef(<[arg]>);
|
float <[arg]>;
|
float <[arg]>;
|
|
|
|
|
DESCRIPTION
|
DESCRIPTION
|
These functions provide information on the floating point
|
These functions provide information on the floating point
|
argument supplied.
|
argument supplied.
|
|
|
There are five major number formats -
|
There are five major number formats -
|
o+
|
o+
|
o zero
|
o zero
|
a number which contains all zero bits.
|
a number which contains all zero bits.
|
o subnormal
|
o subnormal
|
Is used to represent number with a zero exponent, but a non zero fraction.
|
Is used to represent number with a zero exponent, but a non zero fraction.
|
o normal
|
o normal
|
A number with an exponent, and a fraction
|
A number with an exponent, and a fraction
|
o infinity
|
o infinity
|
A number with an all 1's exponent and a zero fraction.
|
A number with an all 1's exponent and a zero fraction.
|
o NAN
|
o NAN
|
A number with an all 1's exponent and a non zero fraction.
|
A number with an all 1's exponent and a non zero fraction.
|
|
|
o-
|
o-
|
|
|
<<isnan>> returns 1 if the argument is a nan. <<isinf>>
|
<<isnan>> returns 1 if the argument is a nan. <<isinf>>
|
returns 1 if the argument is infinity. <<finite>> returns 1 if the
|
returns 1 if the argument is infinity. <<finite>> returns 1 if the
|
argument is zero, subnormal or normal.
|
argument is zero, subnormal or normal.
|
|
|
The <<isnanf>>, <<isinff>> and <<finitef>> perform the same
|
The <<isnanf>>, <<isinff>> and <<finitef>> perform the same
|
operations as their <<isnan>>, <<isinf>> and <<finite>>
|
operations as their <<isnan>>, <<isinf>> and <<finite>>
|
counterparts, but on single precision floating point numbers.
|
counterparts, but on single precision floating point numbers.
|
|
|
QUICKREF
|
QUICKREF
|
isnan - pure
|
isnan - pure
|
QUICKREF
|
QUICKREF
|
isinf - pure
|
isinf - pure
|
QUICKREF
|
QUICKREF
|
finite - pure
|
finite - pure
|
QUICKREF
|
QUICKREF
|
isnan - pure
|
isnan - pure
|
QUICKREF
|
QUICKREF
|
isinf - pure
|
isinf - pure
|
QUICKREF
|
QUICKREF
|
finite - pure
|
finite - pure
|
*/
|
*/
|
|
|
/*
|
/*
|
* isnan(x) returns 1 is x is nan, else 0;
|
* isnan(x) returns 1 is x is nan, else 0;
|
* no branching!
|
* no branching!
|
*/
|
*/
|
|
|
#include "fdlibm.h"
|
#include "fdlibm.h"
|
|
|
#ifndef _DOUBLE_IS_32BITS
|
#ifndef _DOUBLE_IS_32BITS
|
|
|
#ifdef __STDC__
|
#ifdef __STDC__
|
int isnan(double x)
|
int isnan(double x)
|
#else
|
#else
|
int isnan(x)
|
int isnan(x)
|
double x;
|
double x;
|
#endif
|
#endif
|
{
|
{
|
__int32_t hx,lx;
|
__int32_t hx,lx;
|
EXTRACT_WORDS(hx,lx,x);
|
EXTRACT_WORDS(hx,lx,x);
|
hx &= 0x7fffffff;
|
hx &= 0x7fffffff;
|
hx |= (__uint32_t)(lx|(-lx))>>31;
|
hx |= (__uint32_t)(lx|(-lx))>>31;
|
hx = 0x7ff00000 - hx;
|
hx = 0x7ff00000 - hx;
|
return (int)(((__uint32_t)(hx))>>31);
|
return (int)(((__uint32_t)(hx))>>31);
|
}
|
}
|
|
|
#endif /* _DOUBLE_IS_32BITS */
|
#endif /* _DOUBLE_IS_32BITS */
|
|
|