From aa7a0213a6ec73470f0c283b785e65fb610b6558 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Wed, 26 Jul 1995 23:59:44 +0000 Subject: [PATCH] Fixed to work with split fixnums: they are signed and have an effective odd word length. --- v8/src/microcode/mul.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v8/src/microcode/mul.c b/v8/src/microcode/mul.c index adbf4a7d5..a3c20ffea 100644 --- a/v8/src/microcode/mul.c +++ b/v8/src/microcode/mul.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: mul.c,v 9.33 1993/02/15 03:39:48 gjr Exp $ +$Id: mul.c,v 9.34 1995/07/26 23:59:44 adams Exp $ Copyright (c) 1987-1993 Massachusetts Institute of Technology @@ -208,8 +208,7 @@ static long Fixnum_Range[2] = {SMALLEST_FIXNUM , BIGGEST_FIXNUM}; #define HALF_WORD_SIZE (((sizeof (long)) * CHAR_BIT) / 2) #define HALF_WORD_MASK ((ONE << HALF_WORD_SIZE) - 1) -#define MAX_MIDDLE (ONE << ((DATUM_LENGTH - 1) - HALF_WORD_SIZE)) -#define MAX_FIXNUM (ONE << DATUM_LENGTH) +#define MAX_MIDDLE ((BIGGEST_FIXNUM + 1) >> HALF_WORD_SIZE) #define ABS(x) (((x) < 0) ? -(x) : (x)) SCHEME_OBJECT @@ -236,6 +235,7 @@ DEFUN (Mul, (Arg1, Arg2), if (Lo_C >= FIXNUM_SIGN_BIT) return (SHARP_F); Middle_C = (Lo_A * Hi_B) + (Hi_A * Lo_B); + if (Middle_C >= MAX_MIDDLE) return (SHARP_F); C = Lo_C + (Middle_C << HALF_WORD_SIZE); @@ -244,7 +244,7 @@ DEFUN (Mul, (Arg1, Arg2), if (Sign || (C == 0)) return (LONG_TO_UNSIGNED_FIXNUM(C)); else - return (LONG_TO_UNSIGNED_FIXNUM(MAX_FIXNUM - C)); + return (LONG_TO_FIXNUM(-C)); } return (SHARP_F); } -- 2.25.1