1 | /* e_hypotf.c -- float version of e_hypot.c. |
2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
3 | */ |
4 | |
5 | /* |
6 | * ==================================================== |
7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
8 | * |
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 |
12 | * is preserved. |
13 | * ==================================================== |
14 | */ |
15 | |
16 | #include <math.h> |
17 | #include <math_private.h> |
18 | #include <libm-alias-finite.h> |
19 | |
20 | float |
21 | __ieee754_hypotf(float x, float y) |
22 | { |
23 | double d_x, d_y; |
24 | int32_t ha, hb; |
25 | |
26 | GET_FLOAT_WORD(ha,x); |
27 | ha &= 0x7fffffff; |
28 | GET_FLOAT_WORD(hb,y); |
29 | hb &= 0x7fffffff; |
30 | if (ha == 0x7f800000 && !issignaling (y)) |
31 | return fabsf(x); |
32 | else if (hb == 0x7f800000 && !issignaling (x)) |
33 | return fabsf(y); |
34 | else if (ha > 0x7f800000 || hb > 0x7f800000) |
35 | return fabsf(x) * fabsf(y); |
36 | else if (ha == 0) |
37 | return fabsf(y); |
38 | else if (hb == 0) |
39 | return fabsf(x); |
40 | |
41 | d_x = (double) x; |
42 | d_y = (double) y; |
43 | |
44 | return (float) sqrt(d_x * d_x + d_y * d_y); |
45 | } |
46 | #ifndef __ieee754_hypotf |
47 | libm_alias_finite (__ieee754_hypotf, __hypotf) |
48 | #endif |
49 | |