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