source: trunk/libs/newlib/src/newlib/libm/mathfp/s_numtest.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.1 KB
Line 
1
2/* @(#)z_numtest.c 1.0 98/08/13 */
3/******************************************************************
4 * Numtest
5 *
6 * Input:
7 *   x - pointer to a floating point value
8 *
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
15 *
16 * Description:
17 *   This routine returns an integer that indicates the character-
18 *   istics of the number that was passed in.
19 *
20 *****************************************************************/
21
22#include "fdlibm.h"
23#include "zmath.h"
24
25#ifndef _DOUBLE_IS_32BITS
26
27int 
28numtest (double x)
29{
30  __uint32_t hx, lx;
31  int exp;
32
33  EXTRACT_WORDS (hx, lx, x);
34
35  exp = (hx & 0x7ff00000) >> 20;
36
37  /* Check for a zero input. */
38  if (x == 0.0)
39    {
40      return (0);
41    }
42
43  /* Check for not a number or infinity. */
44  if (exp == 0x7ff)
45    {
46      if(hx & 0xf0000 || lx)
47        return (NAN);
48      else
49        return (INF);
50    }
51     
52  /* Otherwise it's a finite value. */ 
53  else
54    return (NUM);
55}
56
57#endif /* _DOUBLE_IS_32BITS */
Note: See TracBrowser for help on using the repository browser.