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

Side by Side Diff: fusl/src/math/modf.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 double modf(double x, double *iptr) 3 double modf(double x, double* iptr) {
4 { 4 union {
5 » union {double f; uint64_t i;} u = {x}; 5 double f;
6 » uint64_t mask; 6 uint64_t i;
7 » int e = (int)(u.i>>52 & 0x7ff) - 0x3ff; 7 } u = {x};
8 uint64_t mask;
9 int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff;
8 10
9 » /* no fractional part */ 11 /* no fractional part */
10 » if (e >= 52) { 12 if (e >= 52) {
11 » » *iptr = x; 13 *iptr = x;
12 » » if (e == 0x400 && u.i<<12 != 0) /* nan */ 14 if (e == 0x400 && u.i << 12 != 0) /* nan */
13 » » » return x; 15 return x;
14 » » u.i &= 1ULL<<63; 16 u.i &= 1ULL << 63;
15 » » return u.f; 17 return u.f;
16 » } 18 }
17 19
18 » /* no integral part*/ 20 /* no integral part*/
19 » if (e < 0) { 21 if (e < 0) {
20 » » u.i &= 1ULL<<63; 22 u.i &= 1ULL << 63;
21 » » *iptr = u.f; 23 *iptr = u.f;
22 » » return x; 24 return x;
23 » } 25 }
24 26
25 » mask = -1ULL>>12>>e; 27 mask = -1ULL >> 12 >> e;
26 » if ((u.i & mask) == 0) { 28 if ((u.i & mask) == 0) {
27 » » *iptr = x; 29 *iptr = x;
28 » » u.i &= 1ULL<<63; 30 u.i &= 1ULL << 63;
29 » » return u.f; 31 return u.f;
30 » } 32 }
31 » u.i &= ~mask; 33 u.i &= ~mask;
32 » *iptr = u.f; 34 *iptr = u.f;
33 » return x - u.f; 35 return x - u.f;
34 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698