1 /* e_hypotf.c -- float version of e_hypot.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
16 #include <sys/cdefs.h>
18 #include "math_private.h"
21 hypotf(float x, float y)
23 float a,b,t1,t2,y1,y2,w;
30 if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
33 if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
35 if(ha > 0x58800000) { /* a>2**50 */
36 if(ha >= 0x7f800000) { /* Inf or NaN */
37 /* Use original arg order iff result is NaN; quieten sNaNs. */
38 w = fabsl(x+0.0L)-fabsf(y+0);
39 if(ha == 0x7f800000) w = a;
40 if(hb == 0x7f800000) w = b;
43 /* scale a and b by 2**-68 */
44 ha -= 0x22000000; hb -= 0x22000000; k += 68;
48 if(hb < 0x26800000) { /* b < 2**-50 */
49 if(hb <= 0x007fffff) { /* subnormal b or 0 */
51 SET_FLOAT_WORD(t1,0x7e800000); /* t1=2^126 */
55 } else { /* scale a and b by 2^68 */
56 ha += 0x22000000; /* a *= 2^68 */
57 hb += 0x22000000; /* b *= 2^68 */
63 /* medium size a and b */
66 SET_FLOAT_WORD(t1,ha&0xfffff000);
68 w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
71 SET_FLOAT_WORD(y1,hb&0xfffff000);
73 SET_FLOAT_WORD(t1,(ha+0x00800000)&0xfffff000);
75 w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
78 SET_FLOAT_WORD(t1,(127+k)<<23);