1 /* wf_pow.c -- float version of w_pow.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 * ====================================================
17 * wrapper powf(x,y) return x**y
24 float powf(float x
, float y
) /* wrapper powf */
26 float powf(x
,y
) /* wrapper powf */
31 return __ieee754_powf(x
,y
);
35 z
=__ieee754_powf(x
,y
);
36 if(_LIB_VERSION
== _IEEE_
|| isnanf(y
)) return z
;
40 /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
47 if (_LIB_VERSION
== _IEEE_
||
48 _LIB_VERSION
== _POSIX_
) exc
.retval
= 1.0;
49 else if (!matherr(&exc
)) {
54 return (float)exc
.retval
;
61 /* error only if _LIB_VERSION == _SVID_ */
68 if (_LIB_VERSION
!= _SVID_
) exc
.retval
= 1.0;
69 else if (!matherr(&exc
)) {
74 return (float)exc
.retval
;
76 if(finitef(y
)&&y
<(float)0.0) {
83 if (_LIB_VERSION
== _SVID_
)
86 exc
.retval
= -HUGE_VAL
;
87 if (_LIB_VERSION
== _POSIX_
)
89 else if (!matherr(&exc
)) {
94 return (float)exc
.retval
;
99 if(finitef(x
)&&finitef(y
)) {
101 /* neg**non-integral */
105 exc
.arg1
= (double)x
;
106 exc
.arg2
= (double)y
;
107 if (_LIB_VERSION
== _SVID_
)
110 exc
.retval
= 0.0/0.0; /* X/Open allow NaN */
111 if (_LIB_VERSION
== _POSIX_
)
113 else if (!matherr(&exc
)) {
118 return (float)exc
.retval
;
120 /* powf(x,y) overflow */
124 exc
.arg1
= (double)x
;
125 exc
.arg2
= (double)y
;
126 if (_LIB_VERSION
== _SVID_
) {
129 if(x
<0.0&&rint(y
)!=y
) exc
.retval
= -HUGE
;
131 exc
.retval
= HUGE_VAL
;
133 if(x
<0.0&&rint(y
)!=y
) exc
.retval
= -HUGE_VAL
;
135 if (_LIB_VERSION
== _POSIX_
)
137 else if (!matherr(&exc
)) {
142 return (float)exc
.retval
;
146 if(z
==(float)0.0&&finitef(x
)&&finitef(y
)) {
147 /* powf(x,y) underflow */
148 exc
.type
= UNDERFLOW
;
151 exc
.arg1
= (double)x
;
152 exc
.arg2
= (double)y
;
154 if (_LIB_VERSION
== _POSIX_
)
156 else if (!matherr(&exc
)) {
161 return (float)exc
.retval
;
167 #ifdef _DOUBLE_IS_32BITS
170 double pow(double x
, double y
)
176 return (double) powf((float) x
, (float) y
);
179 #endif /* defined(_DOUBLE_IS_32BITS) */