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

Side by Side Diff: fusl/src/math/rint.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 <float.h> 1 #include <float.h>
2 #include <math.h> 2 #include <math.h>
3 #include <stdint.h> 3 #include <stdint.h>
4 4
5 #if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 5 #if FLT_EVAL_METHOD == 0 || FLT_EVAL_METHOD == 1
6 #define EPS DBL_EPSILON 6 #define EPS DBL_EPSILON
7 #elif FLT_EVAL_METHOD==2 7 #elif FLT_EVAL_METHOD == 2
8 #define EPS LDBL_EPSILON 8 #define EPS LDBL_EPSILON
9 #endif 9 #endif
10 static const double_t toint = 1/EPS; 10 static const double_t toint = 1 / EPS;
11 11
12 double rint(double x) 12 double rint(double x) {
13 { 13 union {
14 » union {double f; uint64_t i;} u = {x}; 14 double f;
15 » int e = u.i>>52 & 0x7ff; 15 uint64_t i;
16 » int s = u.i>>63; 16 } u = {x};
17 » double_t y; 17 int e = u.i >> 52 & 0x7ff;
18 int s = u.i >> 63;
19 double_t y;
18 20
19 » if (e >= 0x3ff+52) 21 if (e >= 0x3ff + 52)
20 » » return x; 22 return x;
21 » if (s) 23 if (s)
22 » » y = x - toint + toint; 24 y = x - toint + toint;
23 » else 25 else
24 » » y = x + toint - toint; 26 y = x + toint - toint;
25 » if (y == 0) 27 if (y == 0)
26 » » return s ? -0.0 : 0; 28 return s ? -0.0 : 0;
27 » return y; 29 return y;
28 } 30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698