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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-newlib/] [newlib-1.17.0/] [newlib/] [libm/] [math/] [w_acos.c] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 jlechner
 
2
/* @(#)w_acos.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
FUNCTION
16
        <<acos>>, <<acosf>>---arc cosine
17
 
18
INDEX
19
        acos
20
INDEX
21
        acosf
22
 
23
ANSI_SYNOPSIS
24
        #include <math.h>
25
        double acos(double <[x]>);
26
        float acosf(float <[x]>);
27
 
28
TRAD_SYNOPSIS
29
        #include <math.h>
30
        double acos(<[x]>)
31
        double <[x]>;
32
 
33
        float acosf(<[x]>)
34
        float <[x]>;
35
 
36
 
37
 
38
DESCRIPTION
39
 
40
        <<acos>> computes the inverse cosine (arc cosine) of the input value.
41
        Arguments to <<acos>> must be in the range @minus{}1 to 1.
42
 
43
        <<acosf>> is identical to <<acos>>, except that it performs
44
        its calculations on <<floats>>.
45
 
46
RETURNS
47
        @ifnottex
48
        <<acos>> and <<acosf>> return values in radians, in the range of 0 to pi.
49
        @end ifnottex
50
        @tex
51
        <<acos>> and <<acosf>> return values in radians, in the range of <<0>> to $\pi$.
52
        @end tex
53
 
54
        If <[x]> is not between @minus{}1 and 1, the returned value is NaN
55
        (not a number) the global variable <<errno>> is set to <<EDOM>>, and a
56
        <<DOMAIN error>> message is sent as standard error output.
57
 
58
        You can modify error handling for these functions using <<matherr>>.
59
 
60
 
61
QUICKREF ANSI SVID POSIX RENTRANT
62
 acos    y,y,y,m
63
 acosf   n,n,n,m
64
 
65
MATHREF
66
 acos, [-1,1], acos(arg),,,
67
 acos, NAN,    arg,DOMAIN,EDOM
68
 
69
MATHREF
70
 acosf, [-1,1], acosf(arg),,,
71
 acosf, NAN,    argf,DOMAIN,EDOM
72
 
73
*/
74
 
75
/*
76
 * wrap_acos(x)
77
 */
78
 
79
#include "fdlibm.h"
80
#include <errno.h>
81
 
82
#ifndef _DOUBLE_IS_32BITS
83
 
84
#ifdef __STDC__
85
        double acos(double x)           /* wrapper acos */
86
#else
87
        double acos(x)                  /* wrapper acos */
88
        double x;
89
#endif
90
{
91
#ifdef _IEEE_LIBM
92
        return __ieee754_acos(x);
93
#else
94
        double z;
95
        struct exception exc;
96
        z = __ieee754_acos(x);
97
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
98
        if(fabs(x)>1.0) {
99
            /* acos(|x|>1) */
100
            exc.type = DOMAIN;
101
            exc.name = "acos";
102
            exc.err = 0;
103
            exc.arg1 = exc.arg2 = x;
104
            exc.retval = nan("");
105
            if (_LIB_VERSION == _POSIX_)
106
               errno = EDOM;
107
            else if (!matherr(&exc)) {
108
               errno = EDOM;
109
            }
110
            if (exc.err != 0)
111
               errno = exc.err;
112
            return exc.retval;
113
        } else
114
            return z;
115
#endif
116
}
117
 
118
#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.