2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software is freely granted, provided that this notice
|
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
2005-10-29 05:21:08 +08:00
|
|
|
<<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
INDEX
|
|
|
|
isnan
|
|
|
|
INDEX
|
|
|
|
isinf
|
|
|
|
INDEX
|
|
|
|
finite
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
isnanf
|
|
|
|
INDEX
|
|
|
|
isinff
|
|
|
|
INDEX
|
|
|
|
finitef
|
|
|
|
|
2017-11-30 16:36:17 +08:00
|
|
|
SYNOPSIS
|
2016-04-05 04:49:31 +08:00
|
|
|
#include <math.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
int isnan(double <[arg]>);
|
|
|
|
int isinf(double <[arg]>);
|
|
|
|
int finite(double <[arg]>);
|
|
|
|
int isnanf(float <[arg]>);
|
|
|
|
int isinff(float <[arg]>);
|
|
|
|
int finitef(float <[arg]>);
|
|
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2003-10-21 02:46:38 +08:00
|
|
|
These functions provide information on the floating-point
|
2000-02-18 03:39:52 +08:00
|
|
|
argument supplied.
|
|
|
|
|
2005-10-29 05:21:08 +08:00
|
|
|
There are five major number formats:
|
2000-02-18 03:39:52 +08:00
|
|
|
o+
|
|
|
|
o zero
|
2005-10-29 05:21:08 +08:00
|
|
|
A number which contains all zero bits.
|
2000-02-18 03:39:52 +08:00
|
|
|
o subnormal
|
2005-10-29 05:21:08 +08:00
|
|
|
A number with a zero exponent but a nonzero fraction.
|
|
|
|
o normal
|
|
|
|
A number with an exponent and a fraction.
|
2000-02-18 03:39:52 +08:00
|
|
|
o infinity
|
|
|
|
A number with an all 1's exponent and a zero fraction.
|
|
|
|
o NAN
|
2003-10-21 02:46:38 +08:00
|
|
|
A number with an all 1's exponent and a nonzero fraction.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
o-
|
|
|
|
|
|
|
|
<<isnan>> returns 1 if the argument is a nan. <<isinf>>
|
|
|
|
returns 1 if the argument is infinity. <<finite>> returns 1 if the
|
|
|
|
argument is zero, subnormal or normal.
|
2006-02-28 07:51:28 +08:00
|
|
|
|
|
|
|
Note that by the C99 standard, <<isnan>> and <<isinf>> are macros
|
|
|
|
taking any type of floating-point and are declared in
|
2016-04-05 04:49:31 +08:00
|
|
|
<<math.h>>. Newlib has chosen to declare these both as functions
|
|
|
|
and as macros in <<math.h>>.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2005-10-29 05:21:08 +08:00
|
|
|
The <<isnanf>>, <<isinff>> and <<finitef>> functions perform the same
|
2000-02-18 03:39:52 +08:00
|
|
|
operations as their <<isnan>>, <<isinf>> and <<finite>>
|
2003-10-21 02:46:38 +08:00
|
|
|
counterparts, but on single-precision floating-point numbers.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
QUICKREF
|
|
|
|
isnan - pure
|
|
|
|
QUICKREF
|
|
|
|
isinf - pure
|
|
|
|
QUICKREF
|
|
|
|
finite - pure
|
|
|
|
QUICKREF
|
|
|
|
isnan - pure
|
|
|
|
QUICKREF
|
|
|
|
isinf - pure
|
|
|
|
QUICKREF
|
|
|
|
finite - pure
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2006-02-28 07:51:28 +08:00
|
|
|
* __isnand(x) returns 1 is x is nan, else 0;
|
2000-02-18 03:39:52 +08:00
|
|
|
* no branching!
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fdlibm.h"
|
|
|
|
|
|
|
|
#ifndef _DOUBLE_IS_32BITS
|
|
|
|
|
2006-02-28 07:51:28 +08:00
|
|
|
int
|
2017-12-04 11:43:30 +08:00
|
|
|
__isnand (double x)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
|
|
|
__int32_t hx,lx;
|
|
|
|
EXTRACT_WORDS(hx,lx,x);
|
|
|
|
hx &= 0x7fffffff;
|
|
|
|
hx |= (__uint32_t)(lx|(-lx))>>31;
|
|
|
|
hx = 0x7ff00000 - hx;
|
|
|
|
return (int)(((__uint32_t)(hx))>>31);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _DOUBLE_IS_32BITS */
|