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

Side by Side Diff: fusl/src/math/nextafter.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « fusl/src/math/nearbyintl.c ('k') | fusl/src/math/nextafterf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "libm.h"
2
3 double nextafter(double x, double y)
4 {
5 union {double f; uint64_t i;} ux={x}, uy={y};
6 uint64_t ax, ay;
7 int e;
8
9 if (isnan(x) || isnan(y))
10 return x + y;
11 if (ux.i == uy.i)
12 return y;
13 ax = ux.i & -1ULL/2;
14 ay = uy.i & -1ULL/2;
15 if (ax == 0) {
16 if (ay == 0)
17 return y;
18 ux.i = (uy.i & 1ULL<<63) | 1;
19 } else if (ax > ay || ((ux.i ^ uy.i) & 1ULL<<63))
20 ux.i--;
21 else
22 ux.i++;
23 e = ux.i >> 52 & 0x7ff;
24 /* raise overflow if ux.f is infinite and x is finite */
25 if (e == 0x7ff)
26 FORCE_EVAL(x+x);
27 /* raise underflow if ux.f is subnormal or zero */
28 if (e == 0)
29 FORCE_EVAL(x*x + ux.f*ux.f);
30 return ux.f;
31 }
OLDNEW
« no previous file with comments | « fusl/src/math/nearbyintl.c ('k') | fusl/src/math/nextafterf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698