1 /* Copyright (C) 1997-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
19 #include <math_private.h>
26 #define float_type double
29 #define CONCATX(a,b) __CONCAT(a,b)
30 #define s(name) CONCATX(name,SUFF)
31 #define m81(func) __m81_u(s(func))
34 s(__ieee754_pow) (float_type x, float_type y)
38 unsigned long x_cond, y_cond;
40 y_cond = __m81_test (y);
41 if (y_cond & __M81_COND_ZERO)
43 if (y_cond & __M81_COND_NAN)
44 return x == 1.0 ? x : x + y;
46 x_cond = __m81_test (x);
47 if (x_cond & __M81_COND_NAN)
50 if (y_cond & __M81_COND_INF)
56 return y_cond & __M81_COND_NEG ? 0 : y;
58 return y_cond & __M81_COND_NEG ? -y : 0;
61 if (s(fabs) (y) == 1.0)
62 return y_cond & __M81_COND_NEG ? 1 / x : x;
66 if (y == 0.5 && !(x_cond & __M81_COND_NEG))
67 return m81(__ieee754_sqrt) (x);
71 __asm ("ftentox%.x %1, %0" : "=f" (z) : "f" (y));
76 __asm ("ftwotox%.x %1, %0" : "=f" (z) : "f" (y));
81 if (x_cond & (__M81_COND_INF | __M81_COND_ZERO) || ax == 1.0)
84 if (y_cond & __M81_COND_NEG)
86 if (x_cond & __M81_COND_NEG)
88 if (y != m81(__rint) (y))
91 z = (z - z) / (z - z);
99 if (x_cond & __M81_COND_NEG)
101 if (y == m81(__rint) (y))
103 z = m81(__ieee754_exp) (y * m81(__ieee754_log) (-x));
105 /* We always use the long double format, since y is already in
106 this format and rounding won't change the result. */
110 GET_LDOUBLE_WORDS (exponent, i0, i1, y);
111 exponent = (exponent & 0x7fff) - 0x3fff;
113 ? i0 & (1 << (31 - exponent))
115 && i1 & (1 << (63 - exponent))))
120 z = (y - y) / (y - y);
123 z = m81(__ieee754_exp) (y * m81(__ieee754_log) (x));
126 strong_alias (s(__ieee754_pow), CONCATX (s(__pow), _finite))