OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [math/] [wf_jn.c] - Blame information for rev 252

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

Line No. Rev Author Line
1 207 jeremybenn
/* wf_jn.c -- float version of w_jn.c.
2
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3
 */
4
 
5
/*
6
 * ====================================================
7
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8
 *
9
 * Developed at SunPro, a Sun Microsystems, Inc. business.
10
 * Permission to use, copy, modify, and distribute this
11
 * software is freely granted, provided that this notice
12
 * is preserved.
13
 * ====================================================
14
 */
15
 
16
#include "fdlibm.h"
17
#include <errno.h>
18
 
19
 
20
#ifdef __STDC__
21
        float jnf(int n, float x)       /* wrapper jnf */
22
#else
23
        float jnf(n,x)                  /* wrapper jnf */
24
        float x; int n;
25
#endif
26
{
27
#ifdef _IEEE_LIBM
28
        return __ieee754_jnf(n,x);
29
#else
30
        float z;
31
        struct exception exc;
32
        z = __ieee754_jnf(n,x);
33
        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
34
        if(fabsf(x)>(float)X_TLOSS) {
35
            /* jnf(|x|>X_TLOSS) */
36
            exc.type = TLOSS;
37
            exc.name = "jnf";
38
            exc.err = 0;
39
            exc.arg1 = (double)n;
40
            exc.arg2 = (double)x;
41
            exc.retval = 0.0;
42
            if (_LIB_VERSION == _POSIX_)
43
                errno = ERANGE;
44
            else if (!matherr(&exc)) {
45
               errno = ERANGE;
46
            }
47
            if (exc.err != 0)
48
               errno = exc.err;
49
            return exc.retval;
50
        } else
51
            return z;
52
#endif
53
}
54
 
55
#ifdef __STDC__
56
        float ynf(int n, float x)       /* wrapper ynf */
57
#else
58
        float ynf(n,x)                  /* wrapper ynf */
59
        float x; int n;
60
#endif
61
{
62
#ifdef _IEEE_LIBM
63
        return __ieee754_ynf(n,x);
64
#else
65
        float z;
66
        struct exception exc;
67
        z = __ieee754_ynf(n,x);
68
        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
69
        if(x <= (float)0.0){
70
            /* ynf(n,0) = -inf or ynf(x<0) = NaN */
71
#ifndef HUGE_VAL 
72
#define HUGE_VAL inf
73
            double inf = 0.0;
74
 
75
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
76
#endif
77
            exc.type = DOMAIN;  /* should be SING for IEEE */
78
            exc.name = "ynf";
79
            exc.err = 0;
80
            exc.arg1 = (double)n;
81
            exc.arg2 = (double)x;
82
            if (_LIB_VERSION == _SVID_)
83
                exc.retval = -HUGE;
84
            else
85
                exc.retval = -HUGE_VAL;
86
            if (_LIB_VERSION == _POSIX_)
87
                errno = EDOM;
88
            else if (!matherr(&exc)) {
89
                errno = EDOM;
90
            }
91
            if (exc.err != 0)
92
               errno = exc.err;
93
            return (float)exc.retval;
94
        }
95
        if(x>(float)X_TLOSS) {
96
            /* ynf(x>X_TLOSS) */
97
            exc.type = TLOSS;
98
            exc.name = "ynf";
99
            exc.err = 0;
100
            exc.arg1 = (double)n;
101
            exc.arg2 = (double)x;
102
            exc.retval = 0.0;
103
            if (_LIB_VERSION == _POSIX_)
104
                errno = ERANGE;
105
            else if (!matherr(&exc)) {
106
                errno = ERANGE;
107
            }
108
            if (exc.err != 0)
109
               errno = exc.err;
110
            return (float)exc.retval;
111
        } else
112
            return z;
113
#endif
114
}
115
 
116
#ifdef _DOUBLE_IS_32BITS
117
 
118
#ifdef __STDC__
119
        double jn(int n, double x)
120
#else
121
        double jn(n,x)
122
        double x; int n;
123
#endif
124
{
125
        return (double) jnf(n, (float) x);
126
}
127
 
128
#ifdef __STDC__
129
        double yn(int n, double x)
130
#else
131
        double yn(n,x)
132
        double x; int n;
133
#endif
134
{
135
        return (double) ynf(n, (float) x);
136
}
137
 
138
#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.