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

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

Powered by Google App Engine
This is Rietveld 408576698