several bug fixes after test-suite
This commit is contained in:
parent
f27e9ca63e
commit
34d54a20b1
2 changed files with 13 additions and 2 deletions
|
@ -38,11 +38,11 @@ exp(double x)
|
|||
|
||||
if (x <= M_LN_MIN_D) {
|
||||
if (x < M_LN_MIN_D) errno = ERANGE;
|
||||
return DBL_MIN;
|
||||
return 0.0;
|
||||
}
|
||||
if (x >= M_LN_MAX_D) {
|
||||
if (x > M_LN_MAX_D) errno = ERANGE;
|
||||
return DBL_MAX;
|
||||
return HUGE_VAL;
|
||||
}
|
||||
|
||||
if (negative) x = -x;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
/* $Header$ */
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <errno.h>
|
||||
|
||||
double
|
||||
ldexp(double fl, int exp)
|
||||
|
@ -12,6 +14,7 @@ ldexp(double fl, int exp)
|
|||
int sign = 1;
|
||||
int currexp;
|
||||
|
||||
if (fl == 0.0) return 0.0;
|
||||
if (fl<0) {
|
||||
fl = -fl;
|
||||
sign = -1;
|
||||
|
@ -19,6 +22,10 @@ ldexp(double fl, int exp)
|
|||
fl = frexp(fl,&currexp);
|
||||
exp += currexp;
|
||||
if (exp > 0) {
|
||||
if (exp > DBL_MAX_EXP) {
|
||||
errno = ERANGE;
|
||||
return sign * HUGE_VAL;
|
||||
}
|
||||
while (exp>30) {
|
||||
fl *= (double) (1L << 30);
|
||||
exp -= 30;
|
||||
|
@ -26,6 +33,10 @@ ldexp(double fl, int exp)
|
|||
fl *= (double) (1L << exp);
|
||||
}
|
||||
else {
|
||||
/* number need not be normalized */
|
||||
if (exp < DBL_MIN_EXP - DBL_MANT_DIG) {
|
||||
return 0.0;
|
||||
}
|
||||
while (exp<-30) {
|
||||
fl /= (double) (1L << 30);
|
||||
exp += 30;
|
||||
|
|
Loading…
Reference in a new issue