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 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 62 ansi svid posix rentrant 63 acos y,y,y,m 64 acosf n,n,n,m 65 66 MATHREF 67 acos, [-1,1], acos(arg),,, 68 acos, NAN, arg,DOMAIN,EDOM 69 70 MATHREF 71 acosf, [-1,1], acosf(arg),,, 72 acosf, NAN, argf,DOMAIN,EDOM 73 74 */ 75 76 /* 77 * wrap_acos(x) 78 */ 79 80 #include "fdlibm.h" 81 #include <errno.h> 82 83 #ifndef _DOUBLE_IS_32BITS 84 85 #ifdef __STDC__ acos(double x)86 double acos(double x) /* wrapper acos */ 87 #else 88 double acos(x) /* wrapper acos */ 89 double x; 90 #endif 91 { 92 #ifdef _IEEE_LIBM 93 return __ieee754_acos(x); 94 #else 95 double z; 96 struct exception exc; 97 z = __ieee754_acos(x); 98 if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; 99 if(fabs(x)>1.0) { 100 /* acos(|x|>1) */ 101 exc.type = DOMAIN; 102 exc.name = "acos"; 103 exc.err = 0; 104 exc.arg1 = exc.arg2 = x; 105 exc.retval = nan(""); 106 if (_LIB_VERSION == _POSIX_) 107 errno = EDOM; 108 else if (!matherr(&exc)) { 109 errno = EDOM; 110 } 111 if (exc.err != 0) 112 errno = exc.err; 113 return exc.retval; 114 } else 115 return z; 116 #endif 117 } 118 119 #endif /* defined(_DOUBLE_IS_32BITS) */ 120