Paolo Bonzini wrote:
[EMAIL PROTECTED] wrote:
_______________________________________________
help-smalltalk mailing list
[email protected]
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  <[EMAIL PROTECTED]>

        * 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
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to