version 1.1.1.1, 1994/02/11 17:52:19 |
version 1.6, 1994/08/18 23:06:23 |
|
|
|
|
/* @(#)s_atan.c 5.1 93/09/24 */ |
/* @(#)s_atan.c 5.1 93/09/24 */ |
/* |
/* |
* ==================================================== |
* ==================================================== |
|
|
* software is freely granted, provided that this notice |
* software is freely granted, provided that this notice |
* is preserved. |
* is preserved. |
* ==================================================== |
* ==================================================== |
* |
|
*/ |
*/ |
|
|
|
#ifndef lint |
|
static char rcsid[] = "$Id$"; |
|
#endif |
|
|
/* atan(x) |
/* atan(x) |
* Method |
* Method |
* 1. Reduce x to positive by atan(x) = -atan(-x). |
* 1. Reduce x to positive by atan(x) = -atan(-x). |
|
|
* to produce the hexadecimal values shown. |
* to produce the hexadecimal values shown. |
*/ |
*/ |
|
|
#include "fdlibm.h" |
#include "math.h" |
|
#include "math_private.h" |
|
|
#ifdef __STDC__ |
#ifdef __STDC__ |
static const double atanhi[] = { |
static const double atanhi[] = { |
|
|
#endif |
#endif |
{ |
{ |
double w,s1,s2,z; |
double w,s1,s2,z; |
int n0,ix,hx,id; |
int32_t ix,hx,id; |
|
|
n0 = ((*(int*)&one)>>29)^1; |
GET_HIGH_WORD(hx,x); |
hx = *(n0+(int*)&x); |
|
ix = hx&0x7fffffff; |
ix = hx&0x7fffffff; |
if(ix>=0x44100000) { /* if |x| >= 2^66 */ |
if(ix>=0x44100000) { /* if |x| >= 2^66 */ |
|
u_int32_t low; |
|
GET_LOW_WORD(low,x); |
if(ix>0x7ff00000|| |
if(ix>0x7ff00000|| |
(ix==0x7ff00000&&(*(1-n0+(int*)&x)!=0))) |
(ix==0x7ff00000&&(low!=0))) |
return x+x; /* NaN */ |
return x+x; /* NaN */ |
if(hx>0) return atanhi[3]+atanlo[3]; |
if(hx>0) return atanhi[3]+atanlo[3]; |
else return -atanhi[3]-atanlo[3]; |
else return -atanhi[3]-atanlo[3]; |