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

Side by Side Diff: fusl/src/math/nextafterl.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 unified diff | Download patch
OLDNEW
1 #include "libm.h" 1 #include "libm.h"
2 2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double nextafterl(long double x, long double y) 4 long double nextafterl(long double x, long double y) {
5 { 5 return nextafter(x, y);
6 » return nextafter(x, y);
7 } 6 }
8 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 7 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
9 long double nextafterl(long double x, long double y) 8 long double nextafterl(long double x, long double y) {
10 { 9 union ldshape ux, uy;
11 » union ldshape ux, uy;
12 10
13 » if (isnan(x) || isnan(y)) 11 if (isnan(x) || isnan(y))
14 » » return x + y; 12 return x + y;
15 » if (x == y) 13 if (x == y)
16 » » return y; 14 return y;
17 » ux.f = x; 15 ux.f = x;
18 » if (x == 0) { 16 if (x == 0) {
19 » » uy.f = y; 17 uy.f = y;
20 » » ux.i.m = 1; 18 ux.i.m = 1;
21 » » ux.i.se = uy.i.se & 0x8000; 19 ux.i.se = uy.i.se & 0x8000;
22 » } else if ((x < y) == !(ux.i.se & 0x8000)) { 20 } else if ((x < y) == !(ux.i.se & 0x8000)) {
23 » » ux.i.m++; 21 ux.i.m++;
24 » » if (ux.i.m << 1 == 0) { 22 if (ux.i.m << 1 == 0) {
25 » » » ux.i.m = 1ULL << 63; 23 ux.i.m = 1ULL << 63;
26 » » » ux.i.se++; 24 ux.i.se++;
27 » » } 25 }
28 » } else { 26 } else {
29 » » if (ux.i.m << 1 == 0) { 27 if (ux.i.m << 1 == 0) {
30 » » » ux.i.se--; 28 ux.i.se--;
31 » » » if (ux.i.se) 29 if (ux.i.se)
32 » » » » ux.i.m = 0; 30 ux.i.m = 0;
33 » » } 31 }
34 » » ux.i.m--; 32 ux.i.m--;
35 » } 33 }
36 » /* raise overflow if ux is infinite and x is finite */ 34 /* raise overflow if ux is infinite and x is finite */
37 » if ((ux.i.se & 0x7fff) == 0x7fff) 35 if ((ux.i.se & 0x7fff) == 0x7fff)
38 » » return x + x; 36 return x + x;
39 » /* raise underflow if ux is subnormal or zero */ 37 /* raise underflow if ux is subnormal or zero */
40 » if ((ux.i.se & 0x7fff) == 0) 38 if ((ux.i.se & 0x7fff) == 0)
41 » » FORCE_EVAL(x*x + ux.f*ux.f); 39 FORCE_EVAL(x * x + ux.f * ux.f);
42 » return ux.f; 40 return ux.f;
43 } 41 }
44 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 42 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
45 long double nextafterl(long double x, long double y) 43 long double nextafterl(long double x, long double y) {
46 { 44 union ldshape ux, uy;
47 » union ldshape ux, uy;
48 45
49 » if (isnan(x) || isnan(y)) 46 if (isnan(x) || isnan(y))
50 » » return x + y; 47 return x + y;
51 » if (x == y) 48 if (x == y)
52 » » return y; 49 return y;
53 » ux.f = x; 50 ux.f = x;
54 » if (x == 0) { 51 if (x == 0) {
55 » » uy.f = y; 52 uy.f = y;
56 » » ux.i.lo = 1; 53 ux.i.lo = 1;
57 » » ux.i.se = uy.i.se & 0x8000; 54 ux.i.se = uy.i.se & 0x8000;
58 » } else if ((x < y) == !(ux.i.se & 0x8000)) { 55 } else if ((x < y) == !(ux.i.se & 0x8000)) {
59 » » ux.i2.lo++; 56 ux.i2.lo++;
60 » » if (ux.i2.lo == 0) 57 if (ux.i2.lo == 0)
61 » » » ux.i2.hi++; 58 ux.i2.hi++;
62 » } else { 59 } else {
63 » » if (ux.i2.lo == 0) 60 if (ux.i2.lo == 0)
64 » » » ux.i2.hi--; 61 ux.i2.hi--;
65 » » ux.i2.lo--; 62 ux.i2.lo--;
66 » } 63 }
67 » /* raise overflow if ux is infinite and x is finite */ 64 /* raise overflow if ux is infinite and x is finite */
68 » if ((ux.i.se & 0x7fff) == 0x7fff) 65 if ((ux.i.se & 0x7fff) == 0x7fff)
69 » » return x + x; 66 return x + x;
70 » /* raise underflow if ux is subnormal or zero */ 67 /* raise underflow if ux is subnormal or zero */
71 » if ((ux.i.se & 0x7fff) == 0) 68 if ((ux.i.se & 0x7fff) == 0)
72 » » FORCE_EVAL(x*x + ux.f*ux.f); 69 FORCE_EVAL(x * x + ux.f * ux.f);
73 » return ux.f; 70 return ux.f;
74 } 71 }
75 #endif 72 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698