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

Side by Side Diff: fusl/src/math/modff.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/modf.c ('k') | fusl/src/math/modfl.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 modff(float x, float *iptr)
4 {
5 union {float f; uint32_t i;} u = {x};
6 uint32_t mask;
7 int e = (int)(u.i>>23 & 0xff) - 0x7f;
8
9 /* no fractional part */
10 if (e >= 23) {
11 *iptr = x;
12 if (e == 0x80 && u.i<<9 != 0) { /* nan */
13 return x;
14 }
15 u.i &= 0x80000000;
16 return u.f;
17 }
18 /* no integral part */
19 if (e < 0) {
20 u.i &= 0x80000000;
21 *iptr = u.f;
22 return x;
23 }
24
25 mask = 0x007fffff>>e;
26 if ((u.i & mask) == 0) {
27 *iptr = x;
28 u.i &= 0x80000000;
29 return u.f;
30 }
31 u.i &= ~mask;
32 *iptr = u.f;
33 return x - u.f;
34 }
OLDNEW
« no previous file with comments | « fusl/src/math/modf.c ('k') | fusl/src/math/modfl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698