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

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

Powered by Google App Engine
This is Rietveld 408576698