mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-24 19:51:11 +00:00
7c10fd3515
[BZ #13840] * sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Rewrite to use double-precision for the calculation instead of scaling.
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
/* 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
|
|
* software is freely granted, provided that this notice
|
|
* is preserved.
|
|
* ====================================================
|
|
*/
|
|
|
|
#include <math.h>
|
|
#include <math_private.h>
|
|
|
|
float
|
|
__ieee754_hypotf(float x, float y)
|
|
{
|
|
double d_x, d_y;
|
|
int32_t ha, hb;
|
|
|
|
GET_FLOAT_WORD(ha,x);
|
|
ha &= 0x7fffffff;
|
|
GET_FLOAT_WORD(hb,y);
|
|
hb &= 0x7fffffff;
|
|
if (ha == 0x7f800000)
|
|
{
|
|
if (x == y)
|
|
return fabsf(y);
|
|
return fabsf(x);
|
|
}
|
|
else if (hb == 0x7f800000)
|
|
{
|
|
if (x == y)
|
|
return fabsf(x);
|
|
return fabsf(y);
|
|
}
|
|
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);
|
|
}
|
|
strong_alias (__ieee754_hypotf, __hypotf_finite)
|