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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [mathfp/] [sf_numtest.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
 
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
 
25
int
26
_DEFUN (numtestf, (float),
27
        float x)
28
{
29
  __int32_t wx;
30
  int exp;
31
 
32
  GET_FLOAT_WORD (wx, x);
33
 
34
  exp = (wx & 0x7f800000) >> 23;
35
 
36
  /* Check for a zero input. */
37
  if (x == 0.0)
38
    {
39
      return (0);
40
    }
41
 
42
  /* Check for not a number or infinity. */
43
  if (exp == 0x7f8)
44
    {
45
      if(wx & 0x7fffff)
46
        return (NAN);
47
      else
48
        return (INF);
49
    }
50
 
51
  /* Otherwise it's a finite value. */
52
  else
53
    return (NUM);
54
}
55
 
56
#ifdef _DOUBLE_IS_32BITS
57
 
58
int numtest (double x)
59
{
60
  return numtestf ((float) x);
61
}
62
 
63
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

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