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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [math/] [s_isnan.c] - Blame information for rev 1774

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

Line No. Rev Author Line
1 39 lampret
 
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
         Is used to represent  number with a zero exponent, but a non zero 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 non zero 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>> perform the same
81
        operations as their <<isnan>>, <<isinf>> and <<finite>>
82
        counterparts, but on single precision floating point numbers.
83
 
84
QUICKREF
85
        isnan - pure
86
QUICKREF
87
        isinf - pure
88
QUICKREF
89
        finite - pure
90
QUICKREF
91
        isnan - pure
92
QUICKREF
93
        isinf - pure
94
QUICKREF
95
        finite - pure
96
*/
97
 
98
/*
99
 * isnan(x) returns 1 is x is nan, else 0;
100
 * no branching!
101
 */
102
 
103
#include "fdlibm.h"
104
 
105
#ifndef _DOUBLE_IS_32BITS
106
 
107
#ifdef __STDC__
108
        int isnan(double x)
109
#else
110
        int isnan(x)
111
        double x;
112
#endif
113
{
114
        __int32_t hx,lx;
115
        EXTRACT_WORDS(hx,lx,x);
116
        hx &= 0x7fffffff;
117
        hx |= (__uint32_t)(lx|(-lx))>>31;
118
        hx = 0x7ff00000 - hx;
119
        return (int)(((__uint32_t)(hx))>>31);
120
}
121
 
122
#endif /* _DOUBLE_IS_32BITS */

powered by: WebSVN 2.1.0

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