help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: [CFT] GNU Smalltalk 2.3.4 close to release


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: [CFT] GNU Smalltalk 2.3.4 close to release
Date: Mon, 28 May 2007 12:01:18 +0200
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)

Paolo Bonzini wrote:
address@hidden wrote:
_______________________________________________
help-smalltalk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Thanks, I'll try to reproduce the failures on Debian G4.

Actually it does not depend on the OS, but rather on the availability of GMP. It is a stupid off-by-one error in LargeInteger division. When the result of the division has a number >=128 in its MSB, the result is turned into a negative number.

The easiest fix is to allocate an extra byte for the result, since #primDivide: is supposed to run on positive numbers only.

Paolo
2007-05-28  Paolo Bonzini  <address@hidden>

        * kernel/LargeInt.st: Fix division when GMP is absent.

--- orig/kernel/LargeInt.st
+++ mod/kernel/LargeInt.st
@@ -1398,7 +1398,7 @@ primDivide: rhs
     n := v size.
     sub := ByteArray new: n.
     m := u size - n.
-    q := ByteArray new: m + 1.
+    q := ByteArray new: m + 2.
 
     "1. Normalize the divisor
      Knuth's algorithm is based on an initial guess for the quotient. The

reply via email to

[Prev in Thread] Current Thread [Next in Thread]