Welcome to mirror list, hosted at ThFree Co, Russian Federation.

s_isnan.c « mathfp « libm « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 776baa239bf869d2a62ae2cf1eea9b84e40e8515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

/* @(#)z_isnan.c 1.0 98/08/13 */

/*
FUNCTION
        <<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test
for exceptional numbers

INDEX
        isnan
INDEX
        isinf
INDEX
        finite

INDEX
        isnanf
INDEX
        isinff
INDEX
        finitef

ANSI_SYNOPSIS
        #include <ieeefp.h>
        int isnan(double <[arg]>);
        int isinf(double <[arg]>);
        int finite(double <[arg]>);
        int isnanf(float <[arg]>);
        int isinff(float <[arg]>);
        int finitef(float <[arg]>);

TRAD_SYNOPSIS
        #include <ieeefp.h>
        int isnan(<[arg]>)
        double <[arg]>;
        int isinf(<[arg]>)
        double <[arg]>;
        int finite(<[arg]>);
        double <[arg]>;
        int isnanf(<[arg]>);
        float <[arg]>;
        int isinff(<[arg]>);
        float <[arg]>;
        int finitef(<[arg]>);
        float <[arg]>;


DESCRIPTION
        These functions provide information on the floating point
        argument supplied.

        There are five major number formats -
        o+
        o zero
         a number which contains all zero bits.
        o subnormal
         Is used to represent  number with a zero exponent, but a non zero fract
ion.
         o normal
          A number with an exponent, and a fraction
        o infinity
          A number with an all 1's exponent and a zero fraction.
        o NAN
          A number with an all 1's exponent and a non zero fraction.

        o-

        <<isnan>> returns 1 if the argument is a nan. <<isinf>>
        returns 1 if the argument is infinity.  <<finite>> returns 1 if the
        argument is zero, subnormal or normal.

        The <<isnanf>>, <<isinff>> and <<finitef>> perform the same
        operations as their <<isnan>>, <<isinf>> and <<finite>>
        counterparts, but on single precision floating point numbers.

QUICKREF
        isnan - pure
QUICKREF
        isinf - pure
QUICKREF
        finite - pure
QUICKREF
        isnan - pure
QUICKREF
        isinf - pure
QUICKREF
        finite - pure
*/


/******************************************************************
 * isnan
 *
 * Input:
 *   x - pointer to a floating point value
 *
 * Output:
 *   An integer that indicates if the number is NaN.
 *
 * Description:
 *   This routine returns an integer that indicates if the number
 *   passed in is NaN (1) or is finite (0).
 *
 *****************************************************************/

#include "fdlibm.h"
#include "zmath.h"

#ifndef _DOUBLE_IS_32BITS

int isnan (double x)
{
  __uint32_t lx, hx;
  int exp;

  EXTRACT_WORDS (hx, lx, x);
  exp = (hx & 0x7ff00000) >> 20;

  if ((exp == 0x7ff) && (hx & 0xf0000 || lx))
    return (1);
  else
    return (0);
}

#endif /* _DOUBLE_IS_32BITS */