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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libm/] [math/] [wf_jn.c] - Blame information for rev 39

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

Line No. Rev Author Line
1 39 lampret
/* 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_ || isnanf(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.retval = 0.0;
39
            if (_LIB_VERSION == _POSIX_)
40
                errno = ERANGE;
41
            else if (!matherr(&exc)) {
42
               errno = ERANGE;
43
            }
44
            if (exc.err != 0)
45
               errno = exc.err;
46
            return exc.retval;
47
        } else
48
            return z;
49
#endif
50
}
51
 
52
#ifdef __STDC__
53
        float ynf(int n, float x)       /* wrapper ynf */
54
#else
55
        float ynf(n,x)                  /* wrapper ynf */
56
        float x; int n;
57
#endif
58
{
59
#ifdef _IEEE_LIBM
60
        return __ieee754_ynf(n,x);
61
#else
62
        float z;
63
        struct exception exc;
64
        z = __ieee754_ynf(n,x);
65
        if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z;
66
        if(x <= (float)0.0){
67
            /* ynf(n,0) = -inf or ynf(x<0) = NaN */
68
#ifndef HUGE_VAL 
69
#define HUGE_VAL inf
70
            double inf = 0.0;
71
 
72
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
73
#endif
74
            exc.type = DOMAIN;  /* should be SING for IEEE */
75
            exc.name = "ynf";
76
            if (_LIB_VERSION == _SVID_)
77
                exc.retval = -HUGE;
78
            else
79
                exc.retval = -HUGE_VAL;
80
            if (_LIB_VERSION == _POSIX_)
81
                errno = EDOM;
82
            else if (!matherr(&exc)) {
83
                errno = EDOM;
84
            }
85
            if (exc.err != 0)
86
               errno = exc.err;
87
            return (float)exc.retval;
88
        }
89
        if(x>(float)X_TLOSS) {
90
            /* ynf(x>X_TLOSS) */
91
            exc.type = TLOSS;
92
            exc.name = "ynf";
93
            exc.retval = 0.0;
94
            if (_LIB_VERSION == _POSIX_)
95
                errno = ERANGE;
96
            else if (!matherr(&exc)) {
97
                errno = ERANGE;
98
            }
99
            if (exc.err != 0)
100
               errno = exc.err;
101
            return (float)exc.retval;
102
        } else
103
            return z;
104
#endif
105
}
106
 
107
#ifdef _DOUBLE_IS_32BITS
108
 
109
#ifdef __STDC__
110
        double jn(int n, double x)
111
#else
112
        double jn(n,x)
113
        double x; int n;
114
#endif
115
{
116
        return (double) jnf(n, (float) x);
117
}
118
 
119
#ifdef __STDC__
120
        double yn(int n, double x)
121
#else
122
        double yn(n,x)
123
        double x; int n;
124
#endif
125
{
126
        return (double) ynf(n, (float) x);
127
}
128
 
129
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

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