needed ldexp routine for exp.c
This commit is contained in:
parent
c09e4ced7e
commit
52a8f7d1f1
|
@ -11,6 +11,38 @@
|
|||
#include <pc_err.h>
|
||||
extern _trp();
|
||||
|
||||
static double
|
||||
ldexp(fl,exp)
|
||||
double fl;
|
||||
int exp;
|
||||
{
|
||||
extern double _fef();
|
||||
int sign = 1;
|
||||
int currexp;
|
||||
|
||||
if (fl<0) {
|
||||
fl = -fl;
|
||||
sign = -1;
|
||||
}
|
||||
fl = _fef(fl,&currexp);
|
||||
exp += currexp;
|
||||
if (exp > 0) {
|
||||
while (exp>30) {
|
||||
fl *= (double) (1L << 30);
|
||||
exp -= 30;
|
||||
}
|
||||
fl *= (double) (1L << exp);
|
||||
}
|
||||
else {
|
||||
while (exp<-30) {
|
||||
fl /= (double) (1L << 30);
|
||||
exp += 30;
|
||||
}
|
||||
fl /= (double) (1L << -exp);
|
||||
}
|
||||
return sign * fl;
|
||||
}
|
||||
|
||||
double
|
||||
_exp(x)
|
||||
double x;
|
||||
|
|
Loading…
Reference in a new issue