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

Side by Side Diff: fusl/src/math/modfl.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/modff.c ('k') | fusl/src/math/nan.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 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double modfl(long double x, long double *iptr)
5 {
6 double d;
7 long double r;
8
9 r = modf(x, &d);
10 *iptr = d;
11 return r;
12 }
13 #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
14
15 static const long double toint = 1/LDBL_EPSILON;
16
17 long double modfl(long double x, long double *iptr)
18 {
19 union ldshape u = {x};
20 int e = (u.i.se & 0x7fff) - 0x3fff;
21 int s = u.i.se >> 15;
22 long double absx;
23 long double y;
24
25 /* no fractional part */
26 if (e >= LDBL_MANT_DIG-1) {
27 *iptr = x;
28 if (isnan(x))
29 return x;
30 return s ? -0.0 : 0.0;
31 }
32
33 /* no integral part*/
34 if (e < 0) {
35 *iptr = s ? -0.0 : 0.0;
36 return x;
37 }
38
39 /* raises spurious inexact */
40 absx = s ? -x : x;
41 y = absx + toint - toint - absx;
42 if (y == 0) {
43 *iptr = x;
44 return s ? -0.0 : 0.0;
45 }
46 if (y > 0)
47 y -= 1;
48 if (s)
49 y = -y;
50 *iptr = x + y;
51 return -y;
52 }
53 #endif
OLDNEW
« no previous file with comments | « fusl/src/math/modff.c ('k') | fusl/src/math/nan.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698