From: Peter Johnson Date: Wed, 3 Oct 2001 07:41:11 +0000 (-0000) Subject: Fix mantissa rounding overflow issue: 0xff -> 0x100, and shift right -> 0x80 is X-Git-Tag: v0.1.0~273 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=17a9427734fb8899d260cb12dd21690d13b4879a;p=yasm Fix mantissa rounding overflow issue: 0xff -> 0x100, and shift right -> 0x80 is not correct except when the 1 bit is explicit. svn path=/trunk/yasm/; revision=257 --- diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index a0488c98..6461f341 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -524,8 +524,9 @@ floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size, BitVector_increment(output); if (BitVector_bit_test(output, mant_bits)) { - /* overflowed, so divide mantissa by 2 (shift right) */ - BitVector_shift_right(output, 0); + /* overflowed, so zero mantissa (and set explicit bit if necessary) */ + BitVector_Empty(output); + BitVector_Bit_Copy(output, mant_bits-1, !implicit1); /* and up the exponent (checking for overflow) */ if (exponent+1 >= EXP_INF) overflow = 1; diff --git a/src/floatnum.c b/src/floatnum.c index a0488c98..6461f341 100644 --- a/src/floatnum.c +++ b/src/floatnum.c @@ -524,8 +524,9 @@ floatnum_get_common(unsigned char *ptr, const floatnum *flt, int byte_size, BitVector_increment(output); if (BitVector_bit_test(output, mant_bits)) { - /* overflowed, so divide mantissa by 2 (shift right) */ - BitVector_shift_right(output, 0); + /* overflowed, so zero mantissa (and set explicit bit if necessary) */ + BitVector_Empty(output); + BitVector_Bit_Copy(output, mant_bits-1, !implicit1); /* and up the exponent (checking for overflow) */ if (exponent+1 >= EXP_INF) overflow = 1;