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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [wf_exp.c] - Blame information for rev 313

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

Line No. Rev Author Line
1 148 jeremybenn
/* wf_exp.c -- float version of w_exp.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
/*
17
 * wrapper expf(x)
18
 */
19
 
20
#include "fdlibm.h"
21
#include <errno.h>
22
 
23
#ifdef __STDC__
24
static const float
25
#else
26
static float
27
#endif
28
o_threshold=  8.8721679688e+01,  /* 0x42b17180 */
29
u_threshold= -1.0397208405e+02;  /* 0xc2cff1b5 */
30
 
31
#ifdef __STDC__
32
        float expf(float x)             /* wrapper expf */
33
#else
34
        float expf(x)                   /* wrapper expf */
35
        float x;
36
#endif
37
{
38
#ifdef _IEEE_LIBM
39
        return __ieee754_expf(x);
40
#else
41
        float z;
42
        struct exception exc;
43
        z = __ieee754_expf(x);
44
        if(_LIB_VERSION == _IEEE_) return z;
45
        if(finitef(x)) {
46
            if(x>o_threshold) {
47
                /* expf(finite) overflow */
48
#ifndef HUGE_VAL
49
#define HUGE_VAL inf
50
                double inf = 0.0;
51
 
52
                SET_HIGH_WORD(inf,0x7ff00000);  /* set inf to infinite */
53
#endif
54
                exc.type = OVERFLOW;
55
                exc.name = "expf";
56
                exc.err = 0;
57
                exc.arg1 = exc.arg2 = (double)x;
58
                if (_LIB_VERSION == _SVID_)
59
                  exc.retval = HUGE;
60
                else
61
                  exc.retval = HUGE_VAL;
62
                if (_LIB_VERSION == _POSIX_)
63
                  errno = ERANGE;
64
                else if (!matherr(&exc)) {
65
                        errno = ERANGE;
66
                }
67
                if (exc.err != 0)
68
                   errno = exc.err;
69
                return exc.retval;
70
            } else if(x<u_threshold) {
71
                /* expf(finite) underflow */
72
                exc.type = UNDERFLOW;
73
                exc.name = "expf";
74
                exc.err = 0;
75
                exc.arg1 = exc.arg2 = (double)x;
76
                exc.retval = 0.0;
77
                if (_LIB_VERSION == _POSIX_)
78
                  errno = ERANGE;
79
                else if (!matherr(&exc)) {
80
                        errno = ERANGE;
81
                }
82
                if (exc.err != 0)
83
                   errno = exc.err;
84
                return exc.retval;
85
            }
86
        }
87
        return z;
88
#endif
89
}
90
 
91
#ifdef _DOUBLE_IS_32BITS
92
 
93
#ifdef __STDC__
94
        double exp(double x)
95
#else
96
        double exp(x)
97
        double x;
98
#endif
99
{
100
        return (double) expf((float) x);
101
}
102
 
103
#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.