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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [mathfp/] [s_isnan.c] - Blame information for rev 57

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

Line No. Rev Author Line
1 56 joel
 
2
/* @(#)z_isnan.c 1.0 98/08/13 */
3
 
4
/*
5
FUNCTION
6
        <<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test
7
for exceptional numbers
8
 
9
INDEX
10
        isnan
11
INDEX
12
        isinf
13
INDEX
14
        finite
15
 
16
INDEX
17
        isnanf
18
INDEX
19
        isinff
20
INDEX
21
        finitef
22
 
23
ANSI_SYNOPSIS
24
        #include <ieeefp.h>
25
        int isnan(double <[arg]>);
26
        int isinf(double <[arg]>);
27
        int finite(double <[arg]>);
28
        int isnanf(float <[arg]>);
29
        int isinff(float <[arg]>);
30
        int finitef(float <[arg]>);
31
 
32
TRAD_SYNOPSIS
33
        #include <ieeefp.h>
34
        int isnan(<[arg]>)
35
        double <[arg]>;
36
        int isinf(<[arg]>)
37
        double <[arg]>;
38
        int finite(<[arg]>);
39
        double <[arg]>;
40
        int isnanf(<[arg]>);
41
        float <[arg]>;
42
        int isinff(<[arg]>);
43
        float <[arg]>;
44
        int finitef(<[arg]>);
45
        float <[arg]>;
46
 
47
 
48
DESCRIPTION
49
        These functions provide information on the floating point
50
        argument supplied.
51
 
52
        There are five major number formats -
53
        o+
54
        o zero
55
         a number which contains all zero bits.
56
        o subnormal
57
         Is used to represent  number with a zero exponent, but a non zero fract
58
ion.
59
         o normal
60
          A number with an exponent, and a fraction
61
        o infinity
62
          A number with an all 1's exponent and a zero fraction.
63
        o NAN
64
          A number with an all 1's exponent and a non zero fraction.
65
 
66
        o-
67
 
68
        <<isnan>> returns 1 if the argument is a nan. <<isinf>>
69
        returns 1 if the argument is infinity.  <<finite>> returns 1 if the
70
        argument is zero, subnormal or normal.
71
 
72
        The <<isnanf>>, <<isinff>> and <<finitef>> perform the same
73
        operations as their <<isnan>>, <<isinf>> and <<finite>>
74
        counterparts, but on single precision floating point numbers.
75
 
76
QUICKREF
77
        isnan - pure
78
QUICKREF
79
        isinf - pure
80
QUICKREF
81
        finite - pure
82
QUICKREF
83
        isnan - pure
84
QUICKREF
85
        isinf - pure
86
QUICKREF
87
        finite - pure
88
*/
89
 
90
 
91
/******************************************************************
92
 * isnan
93
 *
94
 * Input:
95
 *   x - pointer to a floating point value
96
 *
97
 * Output:
98
 *   An integer that indicates if the number is NaN.
99
 *
100
 * Description:
101
 *   This routine returns an integer that indicates if the number
102
 *   passed in is NaN (1) or is finite (0).
103
 *
104
 *****************************************************************/
105
 
106
#include "fdlibm.h"
107
#include "zmath.h"
108
 
109
#ifndef _DOUBLE_IS_32BITS
110
 
111
int isnan (double x)
112
{
113
  __uint32_t lx, hx;
114
  int exp;
115
 
116
  EXTRACT_WORDS (hx, lx, x);
117
  exp = (hx & 0x7ff00000) >> 20;
118
 
119
  if ((exp == 0x7ff) && (hx & 0xf0000 || lx))
120
    return (1);
121
  else
122
    return (0);
123
}
124
 
125
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

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