Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: fusl/src/math/atan2l.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/math/atan2l.c
diff --git a/fusl/src/math/atan2l.c b/fusl/src/math/atan2l.c
index f0937a9794986068b712972342a28fb3500333fa..055da95d57c78b687f12aa32df9cf6d5110b6cbe 100644
--- a/fusl/src/math/atan2l.c
+++ b/fusl/src/math/atan2l.c
@@ -18,68 +18,80 @@
#include "libm.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-long double atan2l(long double y, long double x)
-{
- return atan2(y, x);
+long double atan2l(long double y, long double x) {
+ return atan2(y, x);
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#include "__invtrigl.h"
-long double atan2l(long double y, long double x)
-{
- union ldshape ux, uy;
- long double z;
- int m, ex, ey;
+long double atan2l(long double y, long double x) {
+ union ldshape ux, uy;
+ long double z;
+ int m, ex, ey;
- if (isnan(x) || isnan(y))
- return x+y;
- if (x == 1)
- return atanl(y);
- ux.f = x;
- uy.f = y;
- ex = ux.i.se & 0x7fff;
- ey = uy.i.se & 0x7fff;
- m = 2*(ux.i.se>>15) | uy.i.se>>15;
- if (y == 0) {
- switch(m) {
- case 0:
- case 1: return y; /* atan(+-0,+anything)=+-0 */
- case 2: return 2*pio2_hi; /* atan(+0,-anything) = pi */
- case 3: return -2*pio2_hi; /* atan(-0,-anything) =-pi */
- }
- }
- if (x == 0)
- return m&1 ? -pio2_hi : pio2_hi;
- if (ex == 0x7fff) {
- if (ey == 0x7fff) {
- switch(m) {
- case 0: return pio2_hi/2; /* atan(+INF,+INF) */
- case 1: return -pio2_hi/2; /* atan(-INF,+INF) */
- case 2: return 1.5*pio2_hi; /* atan(+INF,-INF) */
- case 3: return -1.5*pio2_hi; /* atan(-INF,-INF) */
- }
- } else {
- switch(m) {
- case 0: return 0.0; /* atan(+...,+INF) */
- case 1: return -0.0; /* atan(-...,+INF) */
- case 2: return 2*pio2_hi; /* atan(+...,-INF) */
- case 3: return -2*pio2_hi; /* atan(-...,-INF) */
- }
- }
- }
- if (ex+120 < ey || ey == 0x7fff)
- return m&1 ? -pio2_hi : pio2_hi;
- /* z = atan(|y/x|) without spurious underflow */
- if ((m&2) && ey+120 < ex) /* |y/x| < 0x1p-120, x<0 */
- z = 0.0;
- else
- z = atanl(fabsl(y/x));
- switch (m) {
- case 0: return z; /* atan(+,+) */
- case 1: return -z; /* atan(-,+) */
- case 2: return 2*pio2_hi-(z-2*pio2_lo); /* atan(+,-) */
- default: /* case 3 */
- return (z-2*pio2_lo)-2*pio2_hi; /* atan(-,-) */
- }
+ if (isnan(x) || isnan(y))
+ return x + y;
+ if (x == 1)
+ return atanl(y);
+ ux.f = x;
+ uy.f = y;
+ ex = ux.i.se & 0x7fff;
+ ey = uy.i.se & 0x7fff;
+ m = 2 * (ux.i.se >> 15) | uy.i.se >> 15;
+ if (y == 0) {
+ switch (m) {
+ case 0:
+ case 1:
+ return y; /* atan(+-0,+anything)=+-0 */
+ case 2:
+ return 2 * pio2_hi; /* atan(+0,-anything) = pi */
+ case 3:
+ return -2 * pio2_hi; /* atan(-0,-anything) =-pi */
+ }
+ }
+ if (x == 0)
+ return m & 1 ? -pio2_hi : pio2_hi;
+ if (ex == 0x7fff) {
+ if (ey == 0x7fff) {
+ switch (m) {
+ case 0:
+ return pio2_hi / 2; /* atan(+INF,+INF) */
+ case 1:
+ return -pio2_hi / 2; /* atan(-INF,+INF) */
+ case 2:
+ return 1.5 * pio2_hi; /* atan(+INF,-INF) */
+ case 3:
+ return -1.5 * pio2_hi; /* atan(-INF,-INF) */
+ }
+ } else {
+ switch (m) {
+ case 0:
+ return 0.0; /* atan(+...,+INF) */
+ case 1:
+ return -0.0; /* atan(-...,+INF) */
+ case 2:
+ return 2 * pio2_hi; /* atan(+...,-INF) */
+ case 3:
+ return -2 * pio2_hi; /* atan(-...,-INF) */
+ }
+ }
+ }
+ if (ex + 120 < ey || ey == 0x7fff)
+ return m & 1 ? -pio2_hi : pio2_hi;
+ /* z = atan(|y/x|) without spurious underflow */
+ if ((m & 2) && ey + 120 < ex) /* |y/x| < 0x1p-120, x<0 */
+ z = 0.0;
+ else
+ z = atanl(fabsl(y / x));
+ switch (m) {
+ case 0:
+ return z; /* atan(+,+) */
+ case 1:
+ return -z; /* atan(-,+) */
+ case 2:
+ return 2 * pio2_hi - (z - 2 * pio2_lo); /* atan(+,-) */
+ default: /* case 3 */
+ return (z - 2 * pio2_lo) - 2 * pio2_hi; /* atan(-,-) */
+ }
}
#endif

Powered by Google App Engine
This is Rietveld 408576698