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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [e_sinh.c] - Blame information for rev 855

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

Line No. Rev Author Line
1 148 jeremybenn
 
2
/* @(#)e_sinh.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
/* __ieee754_sinh(x)
15
 * Method :
16
 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
17
 *      1. Replace x by |x| (sinh(-x) = -sinh(x)).
18
 *      2.
19
 *                                                  E + E/(E+1)
20
 *          0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
21
 *                                                      2
22
 *
23
 *          22       <= x <= lnovft :  sinh(x) := exp(x)/2
24
 *          lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
25
 *          ln2ovft  <  x           :  sinh(x) := x*shuge (overflow)
26
 *
27
 * Special cases:
28
 *      sinh(x) is |x| if x is +INF, -INF, or NaN.
29
 *      only sinh(0)=0 is exact for finite x.
30
 */
31
 
32
#include "fdlibm.h"
33
 
34
#ifndef _DOUBLE_IS_32BITS
35
 
36
#ifdef __STDC__
37
static const double one = 1.0, shuge = 1.0e307;
38
#else
39
static double one = 1.0, shuge = 1.0e307;
40
#endif
41
 
42
#ifdef __STDC__
43
        double __ieee754_sinh(double x)
44
#else
45
        double __ieee754_sinh(x)
46
        double x;
47
#endif
48
{
49
        double t,w,h;
50
        __int32_t ix,jx;
51
        __uint32_t lx;
52
 
53
    /* High word of |x|. */
54
        GET_HIGH_WORD(jx,x);
55
        ix = jx&0x7fffffff;
56
 
57
    /* x is INF or NaN */
58
        if(ix>=0x7ff00000) return x+x;
59
 
60
        h = 0.5;
61
        if (jx<0) h = -h;
62
    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
63
        if (ix < 0x40360000) {          /* |x|<22 */
64
            if (ix<0x3e300000)          /* |x|<2**-28 */
65
                if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
66
            t = expm1(fabs(x));
67
            if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
68
            return h*(t+t/(t+one));
69
        }
70
 
71
    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
72
        if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
73
 
74
    /* |x| in [log(maxdouble), overflowthresold] */
75
        GET_LOW_WORD(lx,x);
76
       if (ix<0x408633CE || (ix==0x408633ce && lx<=(__uint32_t)0x8fb9f87d)) {
77
            w = __ieee754_exp(0.5*fabs(x));
78
            t = h*w;
79
            return t*w;
80
        }
81
 
82
    /* |x| > overflowthresold, sinh(x) overflow */
83
        return x*shuge;
84
}
85
 
86
#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.