source: trunk/libs/newlib/src/newlib/libm/math/w_sinh.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.4 KB
Line 
1
2/* @(#)w_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
15/*
16FUNCTION
17        <<sinh>>, <<sinhf>>---hyperbolic sine
18
19INDEX
20        sinh
21INDEX
22        sinhf
23
24SYNOPSIS
25        #include <math.h>
26        double sinh(double <[x]>);
27        float  sinhf(float <[x]>);
28
29DESCRIPTION
30        <<sinh>> computes the hyperbolic sine of the argument <[x]>.
31        Angles are specified in radians.   <<sinh>>(<[x]>) is defined as
32        @ifnottex
33        . (exp(<[x]>) - exp(-<[x]>))/2
34        @end ifnottex
35        @tex
36        $${e^x - e^{-x}}\over 2$$
37        @end tex
38
39        <<sinhf>> is identical, save that it takes and returns <<float>> values.
40
41RETURNS
42        The hyperbolic sine of <[x]> is returned. 
43
44        When the correct result is too large to be representable (an
45        overflow),  <<sinh>> returns <<HUGE_VAL>> with the
46        appropriate sign, and sets the global value <<errno>> to
47        <<ERANGE>>.
48
49        You can modify error handling for these functions with <<matherr>>.
50
51PORTABILITY
52        <<sinh>> is ANSI C. 
53        <<sinhf>> is an extension.
54
55QUICKREF
56        sinh ansi pure
57        sinhf - pure
58*/
59
60/*
61 * wrapper sinh(x)
62 */
63
64#include "fdlibm.h"
65#include <errno.h>
66
67#ifndef _DOUBLE_IS_32BITS
68
69#ifdef __STDC__
70        double sinh(double x)           /* wrapper sinh */
71#else
72        double sinh(x)                  /* wrapper sinh */
73        double x;
74#endif
75{
76#ifdef _IEEE_LIBM
77        return __ieee754_sinh(x);
78#else
79        double z; 
80        struct exception exc;
81        z = __ieee754_sinh(x);
82        if(_LIB_VERSION == _IEEE_) return z;
83        if(!finite(z)&&finite(x)) {
84            /* sinh(finite) overflow */
85#ifndef HUGE_VAL
86#define HUGE_VAL inf
87            double inf = 0.0;
88           
89            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
90#endif
91            exc.type = OVERFLOW;
92            exc.name = "sinh";
93            exc.err = 0;
94            exc.arg1 = exc.arg2 = x;
95            if (_LIB_VERSION == _SVID_)
96               exc.retval = ( (x>0.0) ? HUGE : -HUGE);
97            else
98               exc.retval = ( (x>0.0) ? HUGE_VAL : -HUGE_VAL);
99            if (_LIB_VERSION == _POSIX_)
100               errno = ERANGE;
101            else if (!matherr(&exc)) {
102               errno = ERANGE;
103            }
104            if (exc.err != 0)
105               errno = exc.err;
106            return exc.retval;
107        } else
108            return z;
109#endif
110}
111
112#endif /* defined(_DOUBLE_IS_32BITS) */
Note: See TracBrowser for help on using the repository browser.