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

Side by Side Diff: fusl/src/math/hypotf.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 <math.h> 1 #include <math.h>
2 #include <stdint.h> 2 #include <stdint.h>
3 3
4 float hypotf(float x, float y) 4 float hypotf(float x, float y) {
5 { 5 union {
6 » union {float f; uint32_t i;} ux = {x}, uy = {y}, ut; 6 float f;
7 » float_t z; 7 uint32_t i;
8 } ux = {x}, uy = {y}, ut;
9 float_t z;
8 10
9 » ux.i &= -1U>>1; 11 ux.i &= -1U >> 1;
10 » uy.i &= -1U>>1; 12 uy.i &= -1U >> 1;
11 » if (ux.i < uy.i) { 13 if (ux.i < uy.i) {
12 » » ut = ux; 14 ut = ux;
13 » » ux = uy; 15 ux = uy;
14 » » uy = ut; 16 uy = ut;
15 » } 17 }
16 18
17 » x = ux.f; 19 x = ux.f;
18 » y = uy.f; 20 y = uy.f;
19 » if (uy.i == 0xff<<23) 21 if (uy.i == 0xff << 23)
20 » » return y; 22 return y;
21 » if (ux.i >= 0xff<<23 || uy.i == 0 || ux.i - uy.i >= 25<<23) 23 if (ux.i >= 0xff << 23 || uy.i == 0 || ux.i - uy.i >= 25 << 23)
22 » » return x + y; 24 return x + y;
23 25
24 » z = 1; 26 z = 1;
25 » if (ux.i >= (0x7f+60)<<23) { 27 if (ux.i >= (0x7f + 60) << 23) {
26 » » z = 0x1p90f; 28 z = 0x1p90f;
27 » » x *= 0x1p-90f; 29 x *= 0x1p-90f;
28 » » y *= 0x1p-90f; 30 y *= 0x1p-90f;
29 » } else if (uy.i < (0x7f-60)<<23) { 31 } else if (uy.i < (0x7f - 60) << 23) {
30 » » z = 0x1p-90f; 32 z = 0x1p-90f;
31 » » x *= 0x1p90f; 33 x *= 0x1p90f;
32 » » y *= 0x1p90f; 34 y *= 0x1p90f;
33 » } 35 }
34 » return z*sqrtf((double)x*x + (double)y*y); 36 return z * sqrtf((double)x * x + (double)y * y);
35 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698