source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/math/hypotf.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 585 bytes
Line 
1#include <math.h>
2#include <stdint.h>
3
4float 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}
Note: See TracBrowser for help on using the repository browser.