1203 |
void _assure_in_memory (void *p); |
void _assure_in_memory (void *p); |
1204 |
|
|
1205 |
#define FMEM(f) _assure_in_memory(&f) |
#define FMEM(f) _assure_in_memory(&f) |
1206 |
|
|
1207 |
|
#ifdef IEEEFLOAT |
1208 |
|
/* from ieee754.h */ |
1209 |
|
|
1210 |
|
typedef union { |
1211 |
|
float f; |
1212 |
|
|
1213 |
|
/* This is the IEEE 754 single-precision format. */ |
1214 |
|
struct float_bits |
1215 |
|
{ |
1216 |
|
#ifndef LITTLE_END |
1217 |
|
unsigned int negative:1; |
1218 |
|
unsigned int exponent:8; |
1219 |
|
unsigned int mantissa:23; |
1220 |
|
#else /* Big endian. */ |
1221 |
|
unsigned int mantissa:23; |
1222 |
|
unsigned int exponent:8; |
1223 |
|
unsigned int negative:1; |
1224 |
|
#endif /* Little endian. */ |
1225 |
|
} ieee; |
1226 |
|
} IEEE_float; |
1227 |
|
|
1228 |
|
typedef union { |
1229 |
|
|
1230 |
|
double d; |
1231 |
|
|
1232 |
|
/* This is the IEEE 754 double-precision format. */ |
1233 |
|
struct double_bits |
1234 |
|
{ |
1235 |
|
#ifndef LITTLE_END |
1236 |
|
unsigned int negative:1; |
1237 |
|
unsigned int exponent:11; |
1238 |
|
/* Together these comprise the mantissa. */ |
1239 |
|
unsigned int mantissa0:20; |
1240 |
|
unsigned int mantissa1:32; |
1241 |
|
#else /* Big endian. */ |
1242 |
|
/* # if __FLOAT_WORD_ORDER == BIG_ENDIAN */ |
1243 |
|
/* unsigned int mantissa0:20; */ |
1244 |
|
/* unsigned int exponent:11; */ |
1245 |
|
/* unsigned int negative:1; */ |
1246 |
|
/* unsigned int mantissa1:32; */ |
1247 |
|
/* # else */ |
1248 |
|
/* Together these comprise the mantissa. */ |
1249 |
|
unsigned int mantissa1:32; |
1250 |
|
unsigned int mantissa0:20; |
1251 |
|
unsigned int exponent:11; |
1252 |
|
unsigned int negative:1; |
1253 |
|
/* # endif */ |
1254 |
|
#endif /* Little endian. */ |
1255 |
|
} ieee; |
1256 |
|
} IEEE_double; |
1257 |
|
|
1258 |
|
|
1259 |
|
#endif |
1260 |
|
|
1261 |
|
|
1262 |
|
|
1263 |
void |
void |
1264 |
init_num_co(void) |
init_num_co(void) |
1265 |
{ |
{ |
1346 |
#endif |
#endif |
1347 |
#endif |
#endif |
1348 |
|
|
|
#ifdef MV |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
1349 |
#if defined(S3000) && ~defined(DBL_MAX_10_EXP) |
#if defined(S3000) && ~defined(DBL_MAX_10_EXP) |
1350 |
l[0] = 0x7fffffff; |
l[0] = 0x7fffffff; |
1351 |
l[1] = 0xffffffff; |
l[1] = 0xffffffff; |
1381 |
biggest_float = FLT_MAX; |
biggest_float = FLT_MAX; |
1382 |
#endif |
#endif |
1383 |
|
|
1384 |
|
|
|
/* We want the smallest number not satisfying something, |
|
|
and so we go quickly down, and then back up. We have |
|
|
to use a function call for test, since in line code may keep |
|
|
too much precision, while the usual lisp eql,is not |
|
|
in line. |
|
|
We use SMALL as a multiple to come back up by. |
|
|
We use FMEM(double_negative_epsilon) |
|
|
to force the quantity into memory by taking its address |
|
|
and then passing it to a function. |
|
|
*/ |
|
|
|
|
1385 |
#ifdef IEEEFLOAT |
#ifdef IEEEFLOAT |
1386 |
{ |
{ |
1387 |
double div,td; |
IEEE_float ief; |
1388 |
float ts; |
IEEE_double ied; |
|
for (float_epsilon=1.0,div=0.5;(float)div!=1.0;div=1.0-(0.5*(1.0-div))) |
|
|
for (ts=float_epsilon;FMEM(ts),!SF_EQL((float)(1.0+ts),(float)1.0);float_epsilon=ts,ts*=div); |
|
|
|
|
|
for (float_negative_epsilon=1.0,div=0.5;(float)div!=1.0;div=1.0-(0.5*(1.0-div))) |
|
|
for (ts=float_negative_epsilon;FMEM(ts),!SF_EQL((float)(1.0-ts),(float)1.0);float_negative_epsilon=ts,ts*=div); |
|
|
|
|
|
for (double_epsilon=1.0,div=0.5;(double)div!=1.0;div=1.0-(0.5*(1.0-div))) |
|
|
for (td=double_epsilon;FMEM(td),!LF_EQL((double)(1.0+td),(double)1.0);double_epsilon=td,td*=div); |
|
1389 |
|
|
1390 |
for (double_negative_epsilon=1.0,div=0.5;(double)div!=1.0;div=1.0-(0.5*(1.0-div))) |
if (sizeof(ief)!=sizeof(ief.f)) |
1391 |
for (td=double_negative_epsilon;FMEM(td),!LF_EQL((double)(1.0-td),(double)1.0);double_negative_epsilon=td,td*=div); |
FEerror("Bad ieee float definition\n"); |
1392 |
|
if (sizeof(ied)!=sizeof(ied.d)) |
1393 |
|
FEerror("Bad ieee float definition\n"); |
1394 |
|
|
1395 |
|
for (float_epsilon=ief.f=1.0,ief.ieee.mantissa=1; |
1396 |
|
FMEM(ief.f),!SF_EQL((float)(1.0+ief.f),(float)1.0); |
1397 |
|
float_epsilon=ief.f,ief.ieee.exponent--); |
1398 |
|
|
1399 |
|
for (float_negative_epsilon=ief.f=1.0,ief.ieee.mantissa=1; |
1400 |
|
FMEM(ief.f),!SF_EQL((float)(1.0-ief.f),(float)1.0); |
1401 |
|
float_negative_epsilon=ief.f,ief.ieee.exponent--); |
1402 |
|
|
1403 |
|
for (double_epsilon=ied.d=1.0,ied.ieee.mantissa1=1; |
1404 |
|
FMEM(ied.d),!LF_EQL((1.0+ied.d),1.0); |
1405 |
|
double_epsilon=ied.d,ied.ieee.exponent--); |
1406 |
|
/* FIXME double calculations end one iteration too early */ |
1407 |
|
double_epsilon=ied.d; |
1408 |
|
|
1409 |
|
for (double_negative_epsilon=ied.d=1.0,ied.ieee.mantissa1=1; |
1410 |
|
FMEM(ied.d),!LF_EQL((1.0-ied.d),1.0); |
1411 |
|
double_negative_epsilon=ied.d,ied.ieee.exponent--); |
1412 |
|
double_negative_epsilon=ied.d; |
1413 |
|
|
1414 |
} |
} |
1415 |
#else |
#else |
1416 |
|
|
1417 |
|
/* We want the smallest number not satisfying something, |
1418 |
|
and so we go quickly down, and then back up. We have |
1419 |
|
to use a function call for test, since in line code may keep |
1420 |
|
too much precision, while the usual lisp eql,is not |
1421 |
|
in line. |
1422 |
|
We use SMALL as a multiple to come back up by. |
1423 |
|
We use FMEM(double_negative_epsilon) |
1424 |
|
to force the quantity into memory by taking its address |
1425 |
|
and then passing it to a function. |
1426 |
|
*/ |
1427 |
|
|
1428 |
#define SMALL 1.05 |
#define SMALL 1.05 |
1429 |
for (float_epsilon = 1.0; |
for (float_epsilon = 1.0; |
1430 |
FMEM(float_epsilon),!SF_EQL((float)(1.0 + float_epsilon),(float)1.0); |
FMEM(float_epsilon),!SF_EQL((float)(1.0 + float_epsilon),(float)1.0); |