Rev 4872 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* wf_hypot.c -- float version of w_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 | /* |
||
17 | * wrapper hypotf(x,y) |
||
18 | */ |
||
19 | |||
20 | #include "fdlibm.h" |
||
21 | #include |
||
22 | |||
23 | #ifdef __STDC__ |
||
24 | float hypotf(float x, float y) /* wrapper hypotf */ |
||
25 | #else |
||
26 | float hypotf(x,y) /* wrapper hypotf */ |
||
27 | float x,y; |
||
28 | #endif |
||
29 | { |
||
30 | #ifdef _IEEE_LIBM |
||
31 | return __ieee754_hypotf(x,y); |
||
32 | #else |
||
33 | float z; |
||
34 | struct exception exc; |
||
35 | z = __ieee754_hypotf(x,y); |
||
36 | if(_LIB_VERSION == _IEEE_) return z; |
||
37 | if((!finitef(z))&&finitef(x)&&finitef(y)) { |
||
38 | /* hypotf(finite,finite) overflow */ |
||
39 | #ifndef HUGE_VAL |
||
40 | #define HUGE_VAL inf |
||
41 | double inf = 0.0; |
||
42 | |||
43 | SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ |
||
44 | #endif |
||
45 | exc.type = OVERFLOW; |
||
46 | exc.name = "hypotf"; |
||
47 | exc.err = 0; |
||
48 | exc.arg1 = (double)x; |
||
49 | exc.arg2 = (double)y; |
||
50 | if (_LIB_VERSION == _SVID_) |
||
51 | exc.retval = HUGE; |
||
52 | else |
||
53 | exc.retval = HUGE_VAL; |
||
54 | if (_LIB_VERSION == _POSIX_) |
||
55 | errno = ERANGE; |
||
56 | else if (!matherr(&exc)) { |
||
57 | errno = ERANGE; |
||
58 | } |
||
59 | if (exc.err != 0) |
||
60 | errno = exc.err; |
||
61 | return (float)exc.retval; |
||
62 | } else |
||
63 | return z; |
||
64 | #endif |
||
65 | } |
||
66 | |||
67 | #ifdef _DOUBLE_IS_32BITS |
||
68 | |||
69 | #ifdef __STDC__ |
||
70 | double hypot(double x, double y) |
||
71 | #else |
||
72 | double hypot(x,y) |
||
73 | double x,y; |
||
74 | #endif |
||
75 | { |
||
76 | return (double) hypotf((float) x, (float) y); |
||
77 | } |
||
78 | |||
79 | #endif /* defined(_DOUBLE_IS_32BITS) */ |