2 * IBM Accurate Mathematical Library
3 * written by International Business Machines Corp.
4 * Copyright (C) 2001-2016 Free Software Foundation, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 /************************************************************************/
20 /* MODULE_NAME: atnat2.c */
22 /* FUNCTIONS: uatan2 */
27 /* FILES NEEDED: dla.h endian.h mpa.h mydefs.h atnat2.h */
28 /* mpatan.c mpatan2.c mpsqrt.c */
31 /* An ultimate atan2() routine. Given two IEEE double machine numbers y,*/
32 /* x it computes the correctly rounded (to nearest) value of atan2(y,x).*/
34 /* Assumption: Machine arithmetic operations are performed in */
35 /* round to nearest mode of IEEE 754 standard. */
37 /************************************************************************/
47 #include <math_private.h>
48 #include <stap-probe.h>
54 /************************************************************************/
55 /* An ultimate atan2 routine. Given two IEEE double machine numbers y,x */
56 /* it computes the correctly rounded (to nearest) value of atan2(y,x). */
57 /* Assumption: Machine arithmetic operations are performed in */
58 /* round to nearest mode of IEEE 754 standard. */
59 /************************************************************************/
60 static double atan2Mp (double, double, const int[]);
61 /* Fix the sign and return after stage 1 or stage 2 */
63 signArctan2 (double y
, double z
)
65 return __copysign (z
, y
);
68 static double normalized (double, double, double, double);
69 void __mpatan2 (mp_no
*, mp_no
*, mp_no
*, int);
73 __ieee754_atan2 (double y
, double x
)
75 int i
, de
, ux
, dx
, uy
, dy
;
76 static const int pr
[MM
] = { 6, 8, 10, 20, 32 };
77 double ax
, ay
, u
, du
, u9
, ua
, v
, vv
, dv
, t1
, t2
, t3
, t7
, t8
,
78 z
, zz
, cor
, s1
, ss1
, s2
, ss2
;
84 static const int ep
= 59768832, /* 57*16**5 */
85 em
= -59768832; /* -57*16**5 */
89 ux
= num
.i
[HIGH_HALF
];
91 if ((ux
& 0x7ff00000) == 0x7ff00000)
93 if (((ux
& 0x000fffff) | dx
) != 0x00000000)
97 uy
= num
.i
[HIGH_HALF
];
99 if ((uy
& 0x7ff00000) == 0x7ff00000)
101 if (((uy
& 0x000fffff) | dy
) != 0x00000000)
106 if (uy
== 0x00000000)
108 if (dy
== 0x00000000)
110 if ((ux
& 0x80000000) == 0x00000000)
116 else if (uy
== 0x80000000)
118 if (dy
== 0x00000000)
120 if ((ux
& 0x80000000) == 0x00000000)
130 if ((uy
& 0x80000000) == 0x00000000)
137 if (ux
== 0x7ff00000)
139 if (dx
== 0x00000000)
141 if (uy
== 0x7ff00000)
143 if (dy
== 0x00000000)
146 else if (uy
== 0xfff00000)
148 if (dy
== 0x00000000)
153 if ((uy
& 0x80000000) == 0x00000000)
160 else if (ux
== 0xfff00000)
162 if (dx
== 0x00000000)
164 if (uy
== 0x7ff00000)
166 if (dy
== 0x00000000)
169 else if (uy
== 0xfff00000)
171 if (dy
== 0x00000000)
176 if ((uy
& 0x80000000) == 0x00000000)
185 if (uy
== 0x7ff00000)
187 if (dy
== 0x00000000)
190 else if (uy
== 0xfff00000)
192 if (dy
== 0x00000000)
196 SET_RESTORE_ROUND (FE_TONEAREST
);
197 /* either x/y or y/x is very close to zero */
198 ax
= (x
< 0) ? -x
: x
;
199 ay
= (y
< 0) ? -y
: y
;
200 de
= (uy
& 0x7ff00000) - (ux
& 0x7ff00000);
203 return ((y
> 0) ? hpi
.d
: mhpi
.d
);
210 if ((z
= ay
/ ax
) < TWOM1022
)
211 ret
= normalized (ax
, ay
, y
, z
);
213 ret
= signArctan2 (y
, z
);
214 if (fabs (ret
) < DBL_MIN
)
216 double vret
= ret
? ret
: DBL_MIN
;
217 double force_underflow
= vret
* vret
;
218 math_force_eval (force_underflow
);
224 return ((y
> 0) ? opi
.d
: mopi
.d
);
228 /* if either x or y is extremely close to zero, scale abs(x), abs(y). */
229 if (ax
< twom500
.d
|| ay
< twom500
.d
)
235 /* Likewise for large x and y. */
236 if (ax
> two500
.d
|| ay
> two500
.d
)
242 /* x,y which are neither special nor extreme */
246 EMULV (ax
, u
, v
, vv
, t1
, t2
, t3
, t4
, t5
);
247 du
= ((ay
- v
) - vv
) / ax
;
252 EMULV (ay
, u
, v
, vv
, t1
, t2
, t3
, t4
, t5
);
253 du
= ((ax
- v
) - vv
) / ay
;
258 /* (i) x>0, abs(y)< abs(x): atan(ay/ax) */
265 zz
= du
+ u
* v
* (d3
.d
272 if ((z
= u
+ (zz
- u1
.d
* u
)) == u
+ (zz
+ u1
.d
* u
))
273 return signArctan2 (y
, z
);
275 MUL2 (u
, du
, u
, du
, v
, vv
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
276 s1
= v
* (f11
.d
+ v
* (f13
.d
277 + v
* (f15
.d
+ v
* (f17
.d
+ v
* f19
.d
))));
278 ADD2 (f9
.d
, ff9
.d
, s1
, 0, s2
, ss2
, t1
, t2
);
279 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
280 ADD2 (f7
.d
, ff7
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
281 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
282 ADD2 (f5
.d
, ff5
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
283 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
284 ADD2 (f3
.d
, ff3
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
285 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
286 MUL2 (u
, du
, s1
, ss1
, s2
, ss2
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
287 ADD2 (u
, du
, s2
, ss2
, s1
, ss1
, t1
, t2
);
289 if ((z
= s1
+ (ss1
- u5
.d
* s1
)) == s1
+ (ss1
+ u5
.d
* s1
))
290 return signArctan2 (y
, z
);
292 return atan2Mp (x
, y
, pr
);
295 i
= (TWO52
+ TWO8
* u
) - TWO52
;
297 t3
= u
- cij
[i
][0].d
;
298 EADD (t3
, du
, v
, dv
);
301 zz
= v
* t2
+ (dv
* t2
302 + v
* v
* (cij
[i
][3].d
305 + v
* cij
[i
][6].d
))));
309 u9
= u91
.d
; /* u < 1/4 */
312 } /* 1/4 <= u < 1/2 */
316 u9
= u93
.d
; /* 1/2 <= u < 3/4 */
319 } /* 3/4 <= u <= 1 */
320 if ((z
= t1
+ (zz
- u9
* t1
)) == t1
+ (zz
+ u9
* t1
))
321 return signArctan2 (y
, z
);
323 t1
= u
- hij
[i
][0].d
;
324 EADD (t1
, du
, v
, vv
);
325 s1
= v
* (hij
[i
][11].d
329 + v
* hij
[i
][15].d
))));
330 ADD2 (hij
[i
][9].d
, hij
[i
][10].d
, s1
, 0, s2
, ss2
, t1
, t2
);
331 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
332 ADD2 (hij
[i
][7].d
, hij
[i
][8].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
333 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
334 ADD2 (hij
[i
][5].d
, hij
[i
][6].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
335 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
336 ADD2 (hij
[i
][3].d
, hij
[i
][4].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
337 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
338 ADD2 (hij
[i
][1].d
, hij
[i
][2].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
340 if ((z
= s2
+ (ss2
- ub
.d
* s2
)) == s2
+ (ss2
+ ub
.d
* s2
))
341 return signArctan2 (y
, z
);
342 return atan2Mp (x
, y
, pr
);
345 /* (ii) x>0, abs(x)<=abs(y): pi/2-atan(ax/ay) */
355 ESUB (hpi
.d
, u
, t2
, cor
);
356 t3
= ((hpi1
.d
+ cor
) - du
) - zz
;
357 if ((z
= t2
+ (t3
- u2
.d
)) == t2
+ (t3
+ u2
.d
))
358 return signArctan2 (y
, z
);
360 MUL2 (u
, du
, u
, du
, v
, vv
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
363 + v
* (f15
.d
+ v
* (f17
.d
+ v
* f19
.d
))));
364 ADD2 (f9
.d
, ff9
.d
, s1
, 0, s2
, ss2
, t1
, t2
);
365 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
366 ADD2 (f7
.d
, ff7
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
367 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
368 ADD2 (f5
.d
, ff5
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
369 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
370 ADD2 (f3
.d
, ff3
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
371 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
372 MUL2 (u
, du
, s1
, ss1
, s2
, ss2
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
373 ADD2 (u
, du
, s2
, ss2
, s1
, ss1
, t1
, t2
);
374 SUB2 (hpi
.d
, hpi1
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
376 if ((z
= s2
+ (ss2
- u6
.d
)) == s2
+ (ss2
+ u6
.d
))
377 return signArctan2 (y
, z
);
378 return atan2Mp (x
, y
, pr
);
381 i
= (TWO52
+ TWO8
* u
) - TWO52
;
383 v
= (u
- cij
[i
][0].d
) + du
;
385 zz
= hpi1
.d
- v
* (cij
[i
][2].d
389 + v
* cij
[i
][6].d
))));
390 t1
= hpi
.d
- cij
[i
][1].d
;
392 ua
= ua1
.d
; /* w < 1/2 */
394 ua
= ua2
.d
; /* w >= 1/2 */
395 if ((z
= t1
+ (zz
- ua
)) == t1
+ (zz
+ ua
))
396 return signArctan2 (y
, z
);
398 t1
= u
- hij
[i
][0].d
;
399 EADD (t1
, du
, v
, vv
);
401 s1
= v
* (hij
[i
][11].d
405 + v
* hij
[i
][15].d
))));
407 ADD2 (hij
[i
][9].d
, hij
[i
][10].d
, s1
, 0, s2
, ss2
, t1
, t2
);
408 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
409 ADD2 (hij
[i
][7].d
, hij
[i
][8].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
410 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
411 ADD2 (hij
[i
][5].d
, hij
[i
][6].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
412 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
413 ADD2 (hij
[i
][3].d
, hij
[i
][4].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
414 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
415 ADD2 (hij
[i
][1].d
, hij
[i
][2].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
416 SUB2 (hpi
.d
, hpi1
.d
, s2
, ss2
, s1
, ss1
, t1
, t2
);
418 if ((z
= s1
+ (ss1
- uc
.d
)) == s1
+ (ss1
+ uc
.d
))
419 return signArctan2 (y
, z
);
420 return atan2Mp (x
, y
, pr
);
423 /* (iii) x<0, abs(x)< abs(y): pi/2+atan(ax/ay) */
433 + v
* (d11
.d
+ v
* d13
.d
)))));
434 EADD (hpi
.d
, u
, t2
, cor
);
435 t3
= ((hpi1
.d
+ cor
) + du
) + zz
;
436 if ((z
= t2
+ (t3
- u3
.d
)) == t2
+ (t3
+ u3
.d
))
437 return signArctan2 (y
, z
);
439 MUL2 (u
, du
, u
, du
, v
, vv
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
441 + v
* (f13
.d
+ v
* (f15
.d
+ v
* (f17
.d
+ v
* f19
.d
))));
442 ADD2 (f9
.d
, ff9
.d
, s1
, 0, s2
, ss2
, t1
, t2
);
443 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
444 ADD2 (f7
.d
, ff7
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
445 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
446 ADD2 (f5
.d
, ff5
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
447 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
448 ADD2 (f3
.d
, ff3
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
449 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
450 MUL2 (u
, du
, s1
, ss1
, s2
, ss2
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
451 ADD2 (u
, du
, s2
, ss2
, s1
, ss1
, t1
, t2
);
452 ADD2 (hpi
.d
, hpi1
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
454 if ((z
= s2
+ (ss2
- u7
.d
)) == s2
+ (ss2
+ u7
.d
))
455 return signArctan2 (y
, z
);
456 return atan2Mp (x
, y
, pr
);
459 i
= (TWO52
+ TWO8
* u
) - TWO52
;
461 v
= (u
- cij
[i
][0].d
) + du
;
462 zz
= hpi1
.d
+ v
* (cij
[i
][2].d
466 + v
* cij
[i
][6].d
))));
467 t1
= hpi
.d
+ cij
[i
][1].d
;
469 ua
= ua1
.d
; /* w < 1/2 */
471 ua
= ua2
.d
; /* w >= 1/2 */
472 if ((z
= t1
+ (zz
- ua
)) == t1
+ (zz
+ ua
))
473 return signArctan2 (y
, z
);
475 t1
= u
- hij
[i
][0].d
;
476 EADD (t1
, du
, v
, vv
);
477 s1
= v
* (hij
[i
][11].d
481 + v
* hij
[i
][15].d
))));
482 ADD2 (hij
[i
][9].d
, hij
[i
][10].d
, s1
, 0, s2
, ss2
, t1
, t2
);
483 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
484 ADD2 (hij
[i
][7].d
, hij
[i
][8].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
485 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
486 ADD2 (hij
[i
][5].d
, hij
[i
][6].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
487 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
488 ADD2 (hij
[i
][3].d
, hij
[i
][4].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
489 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
490 ADD2 (hij
[i
][1].d
, hij
[i
][2].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
491 ADD2 (hpi
.d
, hpi1
.d
, s2
, ss2
, s1
, ss1
, t1
, t2
);
493 if ((z
= s1
+ (ss1
- uc
.d
)) == s1
+ (ss1
+ uc
.d
))
494 return signArctan2 (y
, z
);
495 return atan2Mp (x
, y
, pr
);
498 /* (iv) x<0, abs(y)<=abs(x): pi-atan(ax/ay) */
505 + v
* (d9
.d
+ v
* (d11
.d
+ v
* d13
.d
)))));
506 ESUB (opi
.d
, u
, t2
, cor
);
507 t3
= ((opi1
.d
+ cor
) - du
) - zz
;
508 if ((z
= t2
+ (t3
- u4
.d
)) == t2
+ (t3
+ u4
.d
))
509 return signArctan2 (y
, z
);
511 MUL2 (u
, du
, u
, du
, v
, vv
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
512 s1
= v
* (f11
.d
+ v
* (f13
.d
+ v
* (f15
.d
+ v
* (f17
.d
+ v
* f19
.d
))));
513 ADD2 (f9
.d
, ff9
.d
, s1
, 0, s2
, ss2
, t1
, t2
);
514 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
515 ADD2 (f7
.d
, ff7
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
516 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
517 ADD2 (f5
.d
, ff5
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
518 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
519 ADD2 (f3
.d
, ff3
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
520 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
521 MUL2 (u
, du
, s1
, ss1
, s2
, ss2
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
522 ADD2 (u
, du
, s2
, ss2
, s1
, ss1
, t1
, t2
);
523 SUB2 (opi
.d
, opi1
.d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
525 if ((z
= s2
+ (ss2
- u8
.d
)) == s2
+ (ss2
+ u8
.d
))
526 return signArctan2 (y
, z
);
527 return atan2Mp (x
, y
, pr
);
530 i
= (TWO52
+ TWO8
* u
) - TWO52
;
532 v
= (u
- cij
[i
][0].d
) + du
;
533 zz
= opi1
.d
- v
* (cij
[i
][2].d
536 + v
* (cij
[i
][5].d
+ v
* cij
[i
][6].d
))));
537 t1
= opi
.d
- cij
[i
][1].d
;
539 ua
= ua1
.d
; /* w < 1/2 */
541 ua
= ua2
.d
; /* w >= 1/2 */
542 if ((z
= t1
+ (zz
- ua
)) == t1
+ (zz
+ ua
))
543 return signArctan2 (y
, z
);
545 t1
= u
- hij
[i
][0].d
;
547 EADD (t1
, du
, v
, vv
);
549 s1
= v
* (hij
[i
][11].d
552 + v
* (hij
[i
][14].d
+ v
* hij
[i
][15].d
))));
554 ADD2 (hij
[i
][9].d
, hij
[i
][10].d
, s1
, 0, s2
, ss2
, t1
, t2
);
555 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
556 ADD2 (hij
[i
][7].d
, hij
[i
][8].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
557 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
558 ADD2 (hij
[i
][5].d
, hij
[i
][6].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
559 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
560 ADD2 (hij
[i
][3].d
, hij
[i
][4].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
561 MUL2 (v
, vv
, s2
, ss2
, s1
, ss1
, t1
, t2
, t3
, t4
, t5
, t6
, t7
, t8
);
562 ADD2 (hij
[i
][1].d
, hij
[i
][2].d
, s1
, ss1
, s2
, ss2
, t1
, t2
);
563 SUB2 (opi
.d
, opi1
.d
, s2
, ss2
, s1
, ss1
, t1
, t2
);
565 if ((z
= s1
+ (ss1
- uc
.d
)) == s1
+ (ss1
+ uc
.d
))
566 return signArctan2 (y
, z
);
567 return atan2Mp (x
, y
, pr
);
570 #ifndef __ieee754_atan2
571 strong_alias (__ieee754_atan2
, __atan2_finite
)
574 /* Treat the Denormalized case */
577 normalized (double ax
, double ay
, double y
, double z
)
580 mp_no mpx
, mpy
, mpz
, mperr
, mpz2
, mpt1
;
582 __dbl_mp (ax
, &mpx
, p
);
583 __dbl_mp (ay
, &mpy
, p
);
584 __dvd (&mpy
, &mpx
, &mpz
, p
);
585 __dbl_mp (ue
.d
, &mpt1
, p
);
586 __mul (&mpz
, &mpt1
, &mperr
, p
);
587 __sub (&mpz
, &mperr
, &mpz2
, p
);
588 __mp_dbl (&mpz2
, &z
, p
);
589 return signArctan2 (y
, z
);
592 /* Stage 3: Perform a multi-Precision computation */
595 atan2Mp (double x
, double y
, const int pr
[])
599 mp_no mpx
, mpy
, mpz
, mpz1
, mpz2
, mperr
, mpt1
;
600 for (i
= 0; i
< MM
; i
++)
603 __dbl_mp (x
, &mpx
, p
);
604 __dbl_mp (y
, &mpy
, p
);
605 __mpatan2 (&mpy
, &mpx
, &mpz
, p
);
606 __dbl_mp (ud
[i
].d
, &mpt1
, p
);
607 __mul (&mpz
, &mpt1
, &mperr
, p
);
608 __add (&mpz
, &mperr
, &mpz1
, p
);
609 __sub (&mpz
, &mperr
, &mpz2
, p
);
610 __mp_dbl (&mpz1
, &z1
, p
);
611 __mp_dbl (&mpz2
, &z2
, p
);
614 LIBC_PROBE (slowatan2
, 4, &p
, &x
, &y
, &z1
);
618 LIBC_PROBE (slowatan2_inexact
, 4, &p
, &x
, &y
, &z1
);
619 return z1
; /*if impossible to do exact computing */