Several fixes
This commit is contained in:
parent
7e8422d810
commit
d32109c18d
|
@ -3,6 +3,9 @@
|
|||
|
||||
#if __STDC__
|
||||
#include <float.h>
|
||||
#else
|
||||
#include <math.h>
|
||||
#define DBL_MAX M_MAX_D
|
||||
#endif
|
||||
|
||||
static char *cvt();
|
||||
|
@ -59,11 +62,9 @@ cvt(value, ndigit, decpt, sign, ecvtflag)
|
|||
}
|
||||
|
||||
*decpt = 0;
|
||||
#if __STDC__
|
||||
if (value >= DBL_MAX) {
|
||||
value = DBL_MAX;
|
||||
}
|
||||
#endif
|
||||
if (value != 0.0) {
|
||||
register struct powers_of_10 *pp = &p10[0];
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@ extern _trp();
|
|||
#include <pc_math.h>
|
||||
#define M_MIN_D DBL_MIN
|
||||
#define M_MAX_D DBL_MAX
|
||||
#define HUGE HUGE_VAL
|
||||
#endif
|
||||
#undef HUGE
|
||||
#define HUGE 1e1000
|
||||
|
||||
static double
|
||||
Ldexp(fl,exp)
|
||||
|
@ -77,7 +78,16 @@ _exp(x)
|
|||
int negative = x < 0;
|
||||
|
||||
if (x <= M_LN_MIN_D) {
|
||||
return M_MIN_D;
|
||||
g = M_MIN_D/4.0;
|
||||
|
||||
if (g != 0.0) {
|
||||
/* unnormalized numbers apparently exist */
|
||||
if (x < (M_LN2 * (DBL_MIN_EXP - 53))) return 0.0;
|
||||
}
|
||||
else {
|
||||
if (x < M_LN_MIN_D) return 0.0;
|
||||
return M_MIN_D;
|
||||
}
|
||||
}
|
||||
if (x >= M_LN_MAX_D) {
|
||||
if (x > M_LN_MAX_D) {
|
||||
|
@ -88,8 +98,6 @@ _exp(x)
|
|||
}
|
||||
if (negative) x = -x;
|
||||
|
||||
/* ??? avoid underflow ??? */
|
||||
|
||||
n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */
|
||||
xn = n;
|
||||
{
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
|
||||
#if __STDC__
|
||||
#include <pc_math.h>
|
||||
#define HUGE HUGE_VAL
|
||||
#include <float.h>
|
||||
#endif
|
||||
#undef HUGE
|
||||
#define HUGE 1e1000
|
||||
|
||||
double
|
||||
_log(x)
|
||||
|
|
|
@ -39,10 +39,11 @@ extern int _unlink();
|
|||
extern long _lseek();
|
||||
|
||||
static int tmpfil() {
|
||||
static char *namebuf[] = "/usr/tmp/plf.xxxxx";
|
||||
int i; char *p,*q;
|
||||
|
||||
i = _getpid();
|
||||
p = "/usr/tmp/plf.xxxxx";
|
||||
p = namebuf;
|
||||
q = p + 13;
|
||||
do
|
||||
*q++ = (i & 07) + '0';
|
||||
|
|
|
@ -26,10 +26,15 @@ extern char *_fcvt();
|
|||
|
||||
#define assert(x) /* nothing */
|
||||
|
||||
#define HUGE_DIG 39 /* log10(maxreal) */
|
||||
#if __STDC__
|
||||
#include <float.h>
|
||||
#define HUGE_DIG DBL_MAX_10_EXP /* log10(maxreal) */
|
||||
#else
|
||||
#define HUGE_DIG 400 /* log10(maxreal) */
|
||||
#endif
|
||||
#define PREC_DIG 80 /* the maximum digits returned by _fcvt() */
|
||||
#define FILL_CHAR '0' /* char printed if all of _fcvt() used */
|
||||
#define BUFSIZE HUGE_DIG + PREC_DIG + 2
|
||||
#define BUFSIZE HUGE_DIG + PREC_DIG + 3
|
||||
|
||||
_wrf(n,w,r,f) int n,w; double r; struct file *f; {
|
||||
char *p,*b; int s,d; char buf[BUFSIZE];
|
||||
|
|
Loading…
Reference in a new issue