1 | |
---|
2 | /* @(#)w_asin.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 | /* |
---|
16 | FUNCTION |
---|
17 | <<asin>>, <<asinf>>---arc sine |
---|
18 | |
---|
19 | INDEX |
---|
20 | asin |
---|
21 | INDEX |
---|
22 | asinf |
---|
23 | |
---|
24 | SYNOPSIS |
---|
25 | #include <math.h> |
---|
26 | double asin(double <[x]>); |
---|
27 | float asinf(float <[x]>); |
---|
28 | |
---|
29 | DESCRIPTION |
---|
30 | |
---|
31 | <<asin>> computes the inverse sine (arc sine) of the argument <[x]>. |
---|
32 | Arguments to <<asin>> must be in the range @minus{}1 to 1. |
---|
33 | |
---|
34 | <<asinf>> is identical to <<asin>>, other than taking and |
---|
35 | returning floats. |
---|
36 | |
---|
37 | You can modify error handling for these routines using <<matherr>>. |
---|
38 | |
---|
39 | RETURNS |
---|
40 | @ifnottex |
---|
41 | <<asin>> returns values in radians, in the range of -pi/2 to pi/2. |
---|
42 | @end ifnottex |
---|
43 | @tex |
---|
44 | <<asin>> returns values in radians, in the range of $-\pi/2$ to $\pi/2$. |
---|
45 | @end tex |
---|
46 | |
---|
47 | If <[x]> is not in the range @minus{}1 to 1, <<asin>> and <<asinf>> |
---|
48 | return NaN (not a number), set the global variable <<errno>> to |
---|
49 | <<EDOM>>, and issue a <<DOMAIN error>> message. |
---|
50 | |
---|
51 | You can change this error treatment using <<matherr>>. |
---|
52 | |
---|
53 | QUICKREF |
---|
54 | ansi svid posix rentrant |
---|
55 | asin y,y,y,m |
---|
56 | asinf n,n,n,m |
---|
57 | |
---|
58 | MATHREF |
---|
59 | asin, -1<=arg<=1, asin(arg),,, |
---|
60 | asin, NAN, arg,EDOM, DOMAIN |
---|
61 | |
---|
62 | MATHREF |
---|
63 | asinf, -1<=arg<=1, asin(arg),,, |
---|
64 | asinf, NAN, arg,EDOM, DOMAIN |
---|
65 | |
---|
66 | |
---|
67 | */ |
---|
68 | |
---|
69 | /* |
---|
70 | * wrapper asin(x) |
---|
71 | */ |
---|
72 | |
---|
73 | |
---|
74 | #include "fdlibm.h" |
---|
75 | #include <errno.h> |
---|
76 | |
---|
77 | #ifndef _DOUBLE_IS_32BITS |
---|
78 | |
---|
79 | #ifdef __STDC__ |
---|
80 | double asin(double x) /* wrapper asin */ |
---|
81 | #else |
---|
82 | double asin(x) /* wrapper asin */ |
---|
83 | double x; |
---|
84 | #endif |
---|
85 | { |
---|
86 | #ifdef _IEEE_LIBM |
---|
87 | return __ieee754_asin(x); |
---|
88 | #else |
---|
89 | double z; |
---|
90 | struct exception exc; |
---|
91 | z = __ieee754_asin(x); |
---|
92 | if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
---|
93 | if(fabs(x)>1.0) { |
---|
94 | /* asin(|x|>1) */ |
---|
95 | exc.type = DOMAIN; |
---|
96 | exc.name = "asin"; |
---|
97 | exc.err = 0; |
---|
98 | exc.arg1 = exc.arg2 = x; |
---|
99 | exc.retval = nan(""); |
---|
100 | if(_LIB_VERSION == _POSIX_) |
---|
101 | errno = EDOM; |
---|
102 | else if (!matherr(&exc)) { |
---|
103 | errno = EDOM; |
---|
104 | } |
---|
105 | if (exc.err != 0) |
---|
106 | errno = exc.err; |
---|
107 | return exc.retval; |
---|
108 | } else |
---|
109 | return z; |
---|
110 | #endif |
---|
111 | } |
---|
112 | |
---|
113 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|