remove cruft for supposedly-buggy clang from or1k & microblaze syscall_arch
[musl.git] / src / math / hypotf.c
blob2fc214b7232e09ab52d5f8b5bb1b10f024b9b8d3
1 #include <math.h>
2 #include <stdint.h>
4 float hypotf(float x, float y)
6 union {float f; uint32_t i;} ux = {x}, uy = {y}, ut;
7 float_t z;
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;
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;
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;
34 return z*sqrtf((double)x*x + (double)y*y);