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

Side by Side Diff: fusl/src/math/rintf.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 5 #if FLT_EVAL_METHOD == 0
6 #define EPS FLT_EPSILON 6 #define EPS FLT_EPSILON
7 #elif FLT_EVAL_METHOD==1 7 #elif FLT_EVAL_METHOD == 1
8 #define EPS DBL_EPSILON 8 #define EPS DBL_EPSILON
9 #elif FLT_EVAL_METHOD==2 9 #elif FLT_EVAL_METHOD == 2
10 #define EPS LDBL_EPSILON 10 #define EPS LDBL_EPSILON
11 #endif 11 #endif
12 static const float_t toint = 1/EPS; 12 static const float_t toint = 1 / EPS;
13 13
14 float rintf(float x) 14 float rintf(float x) {
15 { 15 union {
16 » union {float f; uint32_t i;} u = {x}; 16 float f;
17 » int e = u.i>>23 & 0xff; 17 uint32_t i;
18 » int s = u.i>>31; 18 } u = {x};
19 » float_t y; 19 int e = u.i >> 23 & 0xff;
20 int s = u.i >> 31;
21 float_t y;
20 22
21 » if (e >= 0x7f+23) 23 if (e >= 0x7f + 23)
22 » » return x; 24 return x;
23 » if (s) 25 if (s)
24 » » y = x - toint + toint; 26 y = x - toint + toint;
25 » else 27 else
26 » » y = x + toint - toint; 28 y = x + toint - toint;
27 » if (y == 0) 29 if (y == 0)
28 » » return s ? -0.0f : 0.0f; 30 return s ? -0.0f : 0.0f;
29 » return y; 31 return y;
30 } 32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698