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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libm/] [math/] [wf_exp.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_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
                if (_LIB_VERSION == _SVID_)
57
                  exc.retval = HUGE;
58
                else
59
                  exc.retval = HUGE_VAL;
60
                if (_LIB_VERSION == _POSIX_)
61
                  errno = ERANGE;
62
                else if (!matherr(&exc)) {
63
                        errno = ERANGE;
64
                }
65
                if (exc.err != 0)
66
                   errno = exc.err;
67
                return exc.retval;
68
            } else if(x<u_threshold) {
69
                /* expf(finite) underflow */
70
                exc.type = UNDERFLOW;
71
                exc.name = "expf";
72
                exc.retval = 0.0;
73
                if (_LIB_VERSION == _POSIX_)
74
                  errno = ERANGE;
75
                else if (!matherr(&exc)) {
76
                        errno = ERANGE;
77
                }
78
                if (exc.err != 0)
79
                   errno = exc.err;
80
                return exc.retval;
81
            }
82
        }
83
        return z;
84
#endif
85
}
86
 
87
#ifdef _DOUBLE_IS_32BITS
88
 
89
#ifdef __STDC__
90
        double exp(double x)
91
#else
92
        double exp(x)
93
        double x;
94
#endif
95
{
96
        return (double) expf((float) x);
97
}
98
 
99
#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.