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

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

Powered by Google App Engine
This is Rietveld 408576698