1996-03-05 21:41:30 +00:00
|
|
|
/* e_hypotf.c -- float version of e_hypot.c.
|
|
|
|
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
1997-01-01 15:28:18 +00:00
|
|
|
* software is freely granted, provided that this notice
|
1996-03-05 21:41:30 +00:00
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
|
|
|
*/
|
|
|
|
|
2012-03-09 19:29:16 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <math_private.h>
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2011-10-12 15:27:51 +00:00
|
|
|
float
|
|
|
|
__ieee754_hypotf(float x, float y)
|
1996-03-05 21:41:30 +00:00
|
|
|
{
|
2012-03-14 01:08:58 +00:00
|
|
|
double d_x, d_y;
|
|
|
|
int32_t ha, hb;
|
1996-03-05 21:41:30 +00:00
|
|
|
|
|
|
|
GET_FLOAT_WORD(ha,x);
|
|
|
|
ha &= 0x7fffffff;
|
|
|
|
GET_FLOAT_WORD(hb,y);
|
|
|
|
hb &= 0x7fffffff;
|
2012-03-14 01:08:58 +00:00
|
|
|
if (ha == 0x7f800000)
|
2015-09-15 17:24:23 +00:00
|
|
|
return fabsf(x);
|
2012-03-14 01:08:58 +00:00
|
|
|
else if (hb == 0x7f800000)
|
2015-09-15 17:24:23 +00:00
|
|
|
return fabsf(y);
|
2012-03-14 01:08:58 +00:00
|
|
|
else if (ha > 0x7f800000 || hb > 0x7f800000)
|
|
|
|
return fabsf(x) * fabsf(y);
|
|
|
|
else if (ha == 0)
|
|
|
|
return fabsf(y);
|
|
|
|
else if (hb == 0)
|
|
|
|
return fabsf(x);
|
|
|
|
|
|
|
|
d_x = (double) x;
|
|
|
|
d_y = (double) y;
|
|
|
|
|
|
|
|
return (float) __ieee754_sqrt(d_x * d_x + d_y * d_y);
|
1996-03-05 21:41:30 +00:00
|
|
|
}
|
2011-10-12 15:27:51 +00:00
|
|
|
strong_alias (__ieee754_hypotf, __hypotf_finite)
|