ReactOS 0.4.15-dev-7942-gd23573b
atanf.c File Reference
#include "libm.h"
#include "libm_util.h"
#include "libm_inlines.h"
#include "libm_errno.h"
Include dependency graph for atanf.c:

Go to the source code of this file.

Macros

#define USE_VALF_WITH_FLAGS
 
#define USE_NAN_WITH_FLAGS
 
#define USE_HANDLE_ERRORF
 

Functions

float FN_PROTOTYPE() atanf (float fx)
 

Macro Definition Documentation

◆ USE_HANDLE_ERRORF

#define USE_HANDLE_ERRORF

Definition at line 32 of file atanf.c.

◆ USE_NAN_WITH_FLAGS

#define USE_NAN_WITH_FLAGS

Definition at line 31 of file atanf.c.

◆ USE_VALF_WITH_FLAGS

#define USE_VALF_WITH_FLAGS

Definition at line 30 of file atanf.c.

Function Documentation

◆ atanf()

float FN_PROTOTYPE() atanf ( float  fx)

Definition at line 47 of file atanf.c.

48{
49
50 /* Some constants and split constants. */
51
52 static double piby2 = 1.5707963267948966e+00; /* 0x3ff921fb54442d18 */
53
54 double c, v, s, q, z;
55 unsigned int xnan;
56
57 double x = fx;
58
59 /* Find properties of argument fx. */
60
61 unsigned long long ux, aux, xneg;
62
63 GET_BITS_DP64(x, ux);
64 aux = ux & ~SIGNBIT_DP64;
65 xneg = ux & SIGNBIT_DP64;
66
67 v = x;
68 if (xneg) v = -x;
69
70 /* Argument reduction to range [-7/16,7/16] */
71
72 if (aux < 0x3fdc000000000000) /* v < 7./16. */
73 {
74 x = v;
75 c = 0.0;
76 }
77 else if (aux < 0x3fe6000000000000) /* v < 11./16. */
78 {
79 x = (2.0*v-1.0)/(2.0+v);
80 /* c = arctan(0.5) */
81 c = 4.63647609000806093515e-01; /* 0x3fddac670561bb4f */
82 }
83 else if (aux < 0x3ff3000000000000) /* v < 19./16. */
84 {
85 x = (v-1.0)/(1.0+v);
86 /* c = arctan(1.) */
87 c = 7.85398163397448278999e-01; /* 0x3fe921fb54442d18 */
88 }
89 else if (aux < 0x4003800000000000) /* v < 39./16. */
90 {
91 x = (v-1.5)/(1.0+1.5*v);
92 /* c = arctan(1.5) */
93 c = 9.82793723247329054082e-01; /* 0x3fef730bd281f69b */
94 }
95 else
96 {
97
98 xnan = (aux > PINFBITPATT_DP64);
99
100 if (xnan)
101 {
102 /* x is NaN */
103 unsigned int uhx;
104 GET_BITS_SP32(fx, uhx);
105 return _handle_errorf("atanf", OP_ATAN, uhx|0x00400000, _DOMAIN,
106 0, EDOM, fx, 0.0F, 1);
107 }
108 else if (v > 0x4c80000000000000)
109 { /* abs(x) > 2^26 => arctan(1/x) is
110 insignificant compared to piby2 */
111 if (xneg)
112 return valf_with_flags((float)-piby2, AMD_F_INEXACT);
113 else
114 return valf_with_flags((float)piby2, AMD_F_INEXACT);
115 }
116
117 x = -1.0/v;
118 /* c = arctan(infinity) */
119 c = 1.57079632679489655800e+00; /* 0x3ff921fb54442d18 */
120 }
121
122 /* Core approximation: Remez(2,2) on [-7/16,7/16] */
123
124 s = x*x;
125 q = x*s*
126 (0.296528598819239217902158651186e0 +
127 (0.192324546402108583211697690500e0 +
128 0.470677934286149214138357545549e-2*s)*s)/
129 (0.889585796862432286486651434570e0 +
130 (0.111072499995399550138837673349e1 +
131 0.299309699959659728404442796915e0*s)*s);
132
133 z = c - (q - x);
134
135 if (xneg) z = -z;
136 return (float)z;
137}
float __cdecl _handle_errorf(char *fname, int opcode, unsigned long long value, int type, int flags, int error, float arg1, float arg2, int nargs)
Definition: _handle_error.c:56
#define EDOM
Definition: errno.h:39
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
const GLubyte * c
Definition: glext.h:8905
GLdouble GLdouble z
Definition: glext.h:5874
#define _DOMAIN
Definition: math.h:39
#define c
Definition: ke_i.h:80
#define AMD_F_INEXACT
Definition: libm_new.h:82
#define GET_BITS_SP32(x, ux)
Definition: libm_util.h:105
#define GET_BITS_DP64(x, ux)
Definition: libm_util.h:118
#define PINFBITPATT_DP64
Definition: libm_util.h:53
#define SIGNBIT_DP64
Definition: libm_util.h:44
static const WCHAR aux[]
GLfixed fx
Definition: tritemp.h:484