Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libm / mathfp / sf_numtest.c
blob1ad5862b14edb2b1fa73f1069596c49c958e03ad
2 /* @(#)z_numtestf.c 1.0 98/08/13 */
3 /******************************************************************
4 * Numtest
6 * Input:
7 * x - pointer to a floating point value
9 * Output:
10 * An integer that indicates what kind of number was passed in:
11 * NUM = 3 - a finite value
12 * NAN = 2 - not a number
13 * INF = 1 - an infinite value
14 * 0 - zero
16 * Description:
17 * This routine returns an integer that indicates the character-
18 * istics of the number that was passed in.
20 *****************************************************************/
22 #include "fdlibm.h"
23 #include "zmath.h"
25 int
26 numtestf (float x)
28 __int32_t wx;
29 int exp;
31 GET_FLOAT_WORD (wx, x);
33 exp = (wx & 0x7f800000) >> 23;
35 /* Check for a zero input. */
36 if (x == 0.0)
38 return (0);
41 /* Check for not a number or infinity. */
42 if (exp == 0xff)
44 if(wx & 0x7fffff)
45 return (NAN);
46 else
47 return (INF);
50 /* Otherwise it's a finite value. */
51 else
52 return (NUM);
55 #ifdef _DOUBLE_IS_32BITS
57 int numtest (double x)
59 return numtestf ((float) x);
62 #endif /* defined(_DOUBLE_IS_32BITS) */