Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libm / mathfp / s_numtest.c
bloba01045fa3bacc4c5febdf827efb34ff37084064a
2 /* @(#)z_numtest.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 #ifndef _DOUBLE_IS_32BITS
27 int
28 numtest (double x)
30 __uint32_t hx, lx;
31 int exp;
33 EXTRACT_WORDS (hx, lx, x);
35 exp = (hx & 0x7ff00000) >> 20;
37 /* Check for a zero input. */
38 if (x == 0.0)
40 return (0);
43 /* Check for not a number or infinity. */
44 if (exp == 0x7ff)
46 if(hx & 0xf0000 || lx)
47 return (NAN);
48 else
49 return (INF);
52 /* Otherwise it's a finite value. */
53 else
54 return (NUM);
57 #endif /* _DOUBLE_IS_32BITS */