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

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

Powered by Google App Engine
This is Rietveld 408576698