Use __signbit inline. Write 0.0/0.0 for NaN. Fix typo in test for `y

= 0.5'.
This commit is contained in:
Ulrich Drepper 1997-04-02 14:44:10 +00:00
parent 231e25e2a3
commit 62f075cd3b

View file

@ -27,10 +27,12 @@
#define float_type double #define float_type double
#endif #endif
#define __CONCATX(a,b) __CONCAT(a,b) #define CONCATX(a,b) __CONCAT(a,b)
#define s(name) CONCATX(name,SUFF)
#define m81(func) __m81_u(s(func))
float_type float_type
__CONCATX(__ieee754_pow,SUFF) (float_type x, float_type y) s(__ieee754_pow) (float_type x, float_type y)
{ {
float_type z; float_type z;
float_type ax; float_type ax;
@ -40,24 +42,24 @@ __CONCATX(__ieee754_pow,SUFF) (float_type x, float_type y)
if (x != x || y != y) if (x != x || y != y)
return x + y; return x + y;
if (__m81_u(__CONCATX(__isinf,SUFF)) (y)) if (m81(__isinf) (y))
{ {
ax = __CONCATX(fabs,SUFF) (x); ax = s(fabs) (x);
if (ax == 1) if (ax == 1)
return y - y; return 0.0/0.0;
if (ax > 1) if (ax > 1)
return y > 0 ? y : 0; return y > 0 ? y : 0;
else else
return y < 0 ? -y : 0; return y < 0 ? -y : 0;
} }
if (__CONCATX(fabs,SUFF) (y) == 1) if (s(fabs) (y) == 1)
return y > 0 ? x : 1 / x; return y > 0 ? x : 1 / x;
if (y == 2) if (y == 2)
return x * x; return x * x;
if (y == 0 && x >= 0) if (y == 0.5 && x >= 0)
return __m81_u(__CONCATX(__ieee754_sqrt,SUFF)) (x); return m81(__ieee754_sqrt) (x);
if (x == 10.0) if (x == 10.0)
{ {
@ -70,19 +72,19 @@ __CONCATX(__ieee754_pow,SUFF) (float_type x, float_type y)
return z; return z;
} }
ax = __CONCATX(fabs,SUFF) (x); ax = s(fabs) (x);
if (__m81_u(__CONCATX(__isinf,SUFF)) (x) || x == 0 || ax == 1) if (m81(__isinf) (x) || x == 0 || ax == 1)
{ {
z = ax; z = ax;
if (y < 0) if (y < 0)
z = 1 / z; z = 1 / z;
if (signbit (x)) if (m81(__signbit) (x))
{ {
float_type temp = __m81_u (__CONCATX(__rint,SUFF)) (y); float_type temp = m81(__rint) (y);
if (y != temp) if (y != temp)
{ {
if (x == -1) if (x == -1)
z = (z - z) / (z - z); z = 0.0/0.0;
} }
else else
{ {
@ -105,12 +107,11 @@ __CONCATX(__ieee754_pow,SUFF) (float_type x, float_type y)
if (x < 0.0) if (x < 0.0)
{ {
float_type temp = __m81_u (__CONCATX(__rint,SUFF)) (y); float_type temp = m81(__rint) (y);
if (y == temp) if (y == temp)
{ {
long long i = (long long) y; long long i = (long long) y;
z = (__m81_u(__CONCATX(__ieee754_exp,SUFF)) z = m81(__ieee754_exp) (y * m81(__ieee754_log) (-x));
(y * __m81_u(__CONCATX(__ieee754_log,SUFF)) (-x)));
if (sizeof (float_type) == sizeof (float)) if (sizeof (float_type) == sizeof (float))
{ {
long i = (long) y; long i = (long) y;
@ -126,10 +127,9 @@ __CONCATX(__ieee754_pow,SUFF) (float_type x, float_type y)
} }
} }
else else
z = (x - x) / (x - x); z = 0.0/0.0;
} }
else else
z = (__m81_u(__CONCATX(__ieee754_exp,SUFF)) z = m81(__ieee754_exp) (y * m81(__ieee754_log) (x));
(y * __m81_u(__CONCATX(__ieee754_log,SUFF)) (x)));
return z; return z;
} }