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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
2
/* @(#)s_isnan.c 5.1 93/09/24 */
3
/*
4
 * ====================================================
5
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6
 *
7
 * Developed at SunPro, a Sun Microsystems, Inc. business.
8
 * Permission to use, copy, modify, and distribute this
9
 * software is freely granted, provided that this notice
10
 * is preserved.
11
 * ====================================================
12
 */
13
 
14
/*
15
FUNCTION
16
        <<isnan>>, <<isnanf>>, <<isinf>>, <<isinff>>, <<finite>>, <<finitef>>---test for exceptional numbers
17
 
18
INDEX
19
        isnan
20
INDEX
21
        isinf
22
INDEX
23
        finite
24
 
25
INDEX
26
        isnanf
27
INDEX
28
        isinff
29
INDEX
30
        finitef
31
 
32
ANSI_SYNOPSIS
33
        #include <ieeefp.h>
34
        int isnan(double <[arg]>);
35
        int isinf(double <[arg]>);
36
        int finite(double <[arg]>);
37
        int isnanf(float <[arg]>);
38
        int isinff(float <[arg]>);
39
        int finitef(float <[arg]>);
40
 
41
TRAD_SYNOPSIS
42
        #include <ieeefp.h>
43
        int isnan(<[arg]>)
44
        double <[arg]>;
45
        int isinf(<[arg]>)
46
        double <[arg]>;
47
        int finite(<[arg]>);
48
        double <[arg]>;
49
        int isnanf(<[arg]>);
50
        float <[arg]>;
51
        int isinff(<[arg]>);
52
        float <[arg]>;
53
        int finitef(<[arg]>);
54
        float <[arg]>;
55
 
56
 
57
DESCRIPTION
58
        These functions provide information on the floating-point
59
        argument supplied.
60
 
61
        There are five major number formats:
62
        o+
63
        o zero
64
          A number which contains all zero bits.
65
        o subnormal
66
          A number with a zero exponent but a nonzero fraction.
67
        o normal
68
          A number with an exponent and a fraction.
69
        o infinity
70
          A number with an all 1's exponent and a zero fraction.
71
        o NAN
72
          A number with an all 1's exponent and a nonzero fraction.
73
 
74
        o-
75
 
76
        <<isnan>> returns 1 if the argument is a nan. <<isinf>>
77
        returns 1 if the argument is infinity.  <<finite>> returns 1 if the
78
        argument is zero, subnormal or normal.
79
 
80
        The <<isnanf>>, <<isinff>> and <<finitef>> functions perform the same
81
        operations as their <<isnan>>, <<isinf>> and <<finite>>
82
        counterparts, but on single-precision floating-point numbers.
83
 
84
        It should be noted that the C99 standard dictates that <<isnan>>
85
        and <<isinf>> are macros that operate on multiple types of
86
        floating-point.  The SUSv2 standard declares <<isnan>> as
87
        a function taking double.  Newlib has decided to declare
88
        them both as macros in math.h and as functions in ieeefp.h.
89
 
90
QUICKREF
91
        isnan - pure
92
QUICKREF
93
        isinf - pure
94
QUICKREF
95
        finite - pure
96
QUICKREF
97
        isnan - pure
98
QUICKREF
99
        isinf - pure
100
QUICKREF
101
        finite - pure
102
*/
103
 
104
/*
105
 * isnan(x) returns 1 is x is nan, else 0;
106
 * no branching!
107
 *
108
 * The C99 standard dictates that isnan is a macro taking
109
 * multiple floating-point types while the SUSv2 standard
110
 * notes it is a function taking a double argument.  Newlib
111
 * has chosen to implement it as a macro in <math.h> and
112
 * declare it as a function in <ieeefp.h>.
113
 */
114
 
115
#include "fdlibm.h"
116
#include <ieeefp.h>
117
 
118
#ifndef _DOUBLE_IS_32BITS
119
 
120
#ifdef __STDC__
121
        int isnan(double x)
122
#else
123
        int isnan(x)
124
        double x;
125
#endif
126
{
127
        __int32_t hx,lx;
128
        EXTRACT_WORDS(hx,lx,x);
129
        hx &= 0x7fffffff;
130
        hx |= (__uint32_t)(lx|(-lx))>>31;
131
        hx = 0x7ff00000 - hx;
132
        return (int)(((__uint32_t)(hx))>>31);
133
}
134
 
135
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

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