1 /* Copyright (C) 1997 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #define __LIBC_INTERNAL_MATH_INLINES
21 #include "math_private.h"
27 #define float_type double
30 #define CONCATX(a,b) __CONCAT(a,b)
31 #define s(name) CONCATX(name,SUFF)
32 #define m81(func) __m81_u(s(func))
35 s(__ieee754_pow) (float_type x, float_type y)
39 unsigned long x_cond, y_cond;
41 y_cond = __m81_test (y);
42 if (y_cond & __M81_COND_ZERO)
45 x_cond = __m81_test (x);
46 if ((x_cond | y_cond) & __M81_COND_NAN)
49 if (y_cond & __M81_COND_INF)
55 return y_cond & __M81_COND_NEG ? 0 : y;
57 return y_cond & __M81_COND_NEG ? -y : 0;
61 return y_cond & __M81_COND_NEG ? 1 / x : x;
65 if (y == 0.5 && !(x_cond & __M81_COND_NEG))
66 return m81(__ieee754_sqrt) (x);
70 __asm ("ftentox%.x %1, %0" : "=f" (z) : "f" (y));
75 __asm ("ftwotox%.x %1, %0" : "=f" (z) : "f" (y));
80 if (x_cond & (__M81_COND_INF | __M81_COND_ZERO) || ax == 1)
83 if (y_cond & __M81_COND_NEG)
85 if (x_cond & __M81_COND_NEG)
87 if (y != m81(__rint) (y))
90 z = (z - z) / (z - z);
98 if (x_cond & __M81_COND_NEG)
100 if (y == m81(__rint) (y))
102 z = m81(__ieee754_exp) (y * m81(__ieee754_log) (-x));
104 /* We always use the long double format, since y is already in
105 this format and rounding won't change the result. */
109 GET_LDOUBLE_WORDS (exponent, i0, i1, y);
110 exponent = (exponent & 0x7fff) - 0x3fff;
112 ? i0 & (1 << (31 - exponent))
114 && i1 & (1 << (63 - exponent))))
119 z = (y - y) / (y - y);
122 z = m81(__ieee754_exp) (y * m81(__ieee754_log) (x));