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

Side by Side Diff: fusl/src/math/nexttoward.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 double nexttoward(double x, long double y) 4 double nexttoward(double x, long double y) {
5 { 5 return nextafter(x, y);
6 » return nextafter(x, y);
7 } 6 }
8 #else 7 #else
9 double nexttoward(double x, long double y) 8 double nexttoward(double x, long double y) {
10 { 9 union {
11 » union {double f; uint64_t i;} ux = {x}; 10 double f;
12 » int e; 11 uint64_t i;
12 } ux = {x};
13 int e;
13 14
14 » if (isnan(x) || isnan(y)) 15 if (isnan(x) || isnan(y))
15 » » return x + y; 16 return x + y;
16 » if (x == y) 17 if (x == y)
17 » » return y; 18 return y;
18 » if (x == 0) { 19 if (x == 0) {
19 » » ux.i = 1; 20 ux.i = 1;
20 » » if (signbit(y)) 21 if (signbit(y))
21 » » » ux.i |= 1ULL<<63; 22 ux.i |= 1ULL << 63;
22 » } else if (x < y) { 23 } else if (x < y) {
23 » » if (signbit(x)) 24 if (signbit(x))
24 » » » ux.i--; 25 ux.i--;
25 » » else 26 else
26 » » » ux.i++; 27 ux.i++;
27 » } else { 28 } else {
28 » » if (signbit(x)) 29 if (signbit(x))
29 » » » ux.i++; 30 ux.i++;
30 » » else 31 else
31 » » » ux.i--; 32 ux.i--;
32 » } 33 }
33 » e = ux.i>>52 & 0x7ff; 34 e = ux.i >> 52 & 0x7ff;
34 » /* raise overflow if ux.f is infinite and x is finite */ 35 /* raise overflow if ux.f is infinite and x is finite */
35 » if (e == 0x7ff) 36 if (e == 0x7ff)
36 » » FORCE_EVAL(x+x); 37 FORCE_EVAL(x + x);
37 » /* raise underflow if ux.f is subnormal or zero */ 38 /* raise underflow if ux.f is subnormal or zero */
38 » if (e == 0) 39 if (e == 0)
39 » » FORCE_EVAL(x*x + ux.f*ux.f); 40 FORCE_EVAL(x * x + ux.f * ux.f);
40 » return ux.f; 41 return ux.f;
41 } 42 }
42 #endif 43 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698