From: Guillermo J. Rozas Date: Wed, 15 Feb 1989 18:47:04 +0000 (+0000) Subject: Improve mantissa bit computation so that it takes round-off into account. X-Git-Tag: 20090517-FFI~12272 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=22cc44bae1fc1e8dc118f5f43cda013bdb187e0a;p=mit-scheme.git Improve mantissa bit computation so that it takes round-off into account. --- diff --git a/v7/src/microcode/wsize.c b/v7/src/microcode/wsize.c index e8eabebcf..a925a46b6 100644 --- a/v7/src/microcode/wsize.c +++ b/v7/src/microcode/wsize.c @@ -1,6 +1,6 @@ /* -*-C-*- -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1989 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/wsize.c,v 9.24 1989/02/15 03:29:34 jinx Exp $ */ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/wsize.c,v 9.25 1989/02/15 18:47:04 jinx Exp $ */ #include #include @@ -83,7 +83,7 @@ struct double_probe { main() { - double accum[1], new_accum[1], delta, dtemp; + double accum[3], delta, dtemp; int count, expt_size, char_size, mant_size, double_size, extra; unsigned long to_be_shifted; unsigned bogus; @@ -172,17 +172,23 @@ main() mant_size = 1; accum[0] = 1.0; + accum[1] = 0.0; delta = 0.5; while(true) { - new_accum[0] = (accum[0] + delta); - if ((new_accum[0] == accum[0]) || (mant_size == double_size)) + accum[2] = accum[1]; + accum[1] = (accum[0] + delta); + if ((accum[1] == accum[0]) || + (accum[2] == accum[1]) || + (mant_size == double_size)) break; delta = (delta / ((double) 2.0)); mant_size += 1; } + printf("#define FLONUM_MANTISSA_BITS %d\n", mant_size); + for(errno = 0, expt_size = 0, bogus = 1, dtemp = 0.0; ((errno != ERANGE) && (expt_size <= double_size)); expt_size += 1, bogus <<= 1) @@ -196,7 +202,6 @@ main() expt_size -= 1; printf("#define FLONUM_EXPT_SIZE %d\n", expt_size); - printf("#define FLONUM_MANTISSA_BITS %d\n", mant_size); printf("#define MAX_FLONUM_EXPONENT %d\n", ((1 << expt_size) - 1)); extra = ((2 + expt_size + mant_size) - double_size);