OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libm/] [mathfp/] [s_numtest.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
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
 
27
int
28
_DEFUN (numtest, (double),
29
        double x)
30
{
31
  __uint32_t hx, lx;
32
  int exp;
33
 
34
  EXTRACT_WORDS (hx, lx, x);
35
 
36
  exp = (hx & 0x7ff00000) >> 20;
37
 
38
  /* Check for a zero input. */
39
  if (x == 0.0)
40
    {
41
      return (0);
42
    }
43
 
44
  /* Check for not a number or infinity. */
45
  if (exp == 0x7ff)
46
    {
47
      if(hx & 0xf0000 || lx)
48
        return (NAN);
49
      else
50
        return (INF);
51
    }
52
 
53
  /* Otherwise it's a finite value. */
54
  else
55
    return (NUM);
56
}
57
 
58
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.