2 /* @(#)z_pow.c 1.0 98/08/13 */
6 <<pow>>, <<powf>>---x to the power y
15 double pow(double <[x]>, double <[y]>);
16 float pow(float <[x]>, float <[y]>);
19 <<pow>> and <<powf>> calculate <[x]> raised to the exponent <[y]>.
25 On success, <<pow>> and <<powf>> return the value calculated.
27 When the argument values would produce overflow, <<pow>>
28 returns <<HUGE_VAL>> and set <<errno>> to <<ERANGE>>. If the
29 argument <[x]> passed to <<pow>> or <<powf>> is a negative
30 noninteger, and <[y]> is also not an integer, then <<errno>>
31 is set to <<EDOM>>. If <[x]> and <[y]> are both 0, then
32 <<pow>> and <<powf>> return <<1>>.
35 <<pow>> is ANSI C. <<powf>> is an extension. */
41 #ifndef _DOUBLE_IS_32BITS
43 double pow (double x
, double y
)
45 double d
, k
, t
, r
= 1.0;
46 int n
, sign
, exponent_is_even_int
= 0;
49 GET_HIGH_WORD (px
, x
);
55 /* Exponent y is an integer. */
56 if (modf (ldexp (y
, -1), &t
))
59 exponent_is_even_int
= 0;
64 exponent_is_even_int
= 1;
73 else if ((t
= y
* log (fabs (x
))) >= BIGX
)
81 /* y is not an integer. */
85 else if (exponent_is_even_int
)
102 if ( !k
&& fabs(d
) <= 32767 )
106 if ((sign
= (n
< 0)))
111 if ((unsigned int) n
% 2)
114 n
= (unsigned int) n
/ 2;
124 if ( px
& 0x80000000 )
129 /* y is not an integer. */
137 if (!exponent_is_even_int
)
141 /* y is an odd integer, and x is negative,
142 so the result is negative. */
143 GET_HIGH_WORD (px
, x
);
145 SET_HIGH_WORD (x
, px
);
154 #endif _DOUBLE_IS_32BITS