source: trunk/libs/newlib/src/newlib/libm/mathfp/sf_numtest.c @ 471

Last change on this file since 471 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_numtestf.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
25int 
26numtestf (float x)
27{
28  __int32_t wx;
29  int exp;
30
31  GET_FLOAT_WORD (wx, x);
32
33  exp = (wx & 0x7f800000) >> 23;
34
35  /* Check for a zero input. */
36  if (x == 0.0)
37    {
38      return (0);
39    }
40
41  /* Check for not a number or infinity. */
42  if (exp == 0xff)
43    {
44      if(wx & 0x7fffff)
45        return (NAN);
46      else
47        return (INF);
48    }
49     
50  /* Otherwise it's a finite value. */ 
51  else
52    return (NUM);
53}
54
55#ifdef _DOUBLE_IS_32BITS
56
57int numtest (double x)
58{
59  return numtestf ((float) x);
60}
61
62#endif /* defined(_DOUBLE_IS_32BITS) */
Note: See TracBrowser for help on using the repository browser.