--- a/LargeInteger.st Fri Feb 05 09:27:47 2016 +0000
+++ b/LargeInteger.st Mon Feb 08 06:59:19 2016 +0100
@@ -14,10 +14,10 @@
"{ NameSpace: Smalltalk }"
Integer subclass:#LargeInteger
- instanceVariableNames:'sign digitByteArray'
- classVariableNames:'UseKarazuba'
- poolDictionaries:''
- category:'Magnitude-Numbers'
+ instanceVariableNames:'sign digitByteArray'
+ classVariableNames:'UseKarazuba'
+ poolDictionaries:''
+ category:'Magnitude-Numbers'
!
!LargeInteger class methodsFor:'documentation'!
@@ -2341,17 +2341,20 @@
equalFromInteger:anInteger
"sent when an integer does not know how to compare to the receiver, a largeInt"
+ |otherClass|
+
"/
"/ here, we depend on the fact, that largeinteger
"/ results are always converted to smallInts, if possible.
"/ therefore, a largeInt in the smallInt range is not allowed (possible)
"/
- anInteger class == SmallInteger ifTrue:[^ false ].
- anInteger class == self class ifFalse:[
- ^ super equalFromInteger:anInteger
+ otherClass := anInteger class.
+ otherClass == SmallInteger ifTrue:[^ false ].
+ otherClass == self class ifTrue:[
+ (anInteger sign == sign) ifFalse:[^ false].
+ ^ self absEq:anInteger
].
- (anInteger sign == sign) ifFalse:[^ false].
- ^ self absEq:anInteger
+ ^ super equalFromInteger:anInteger
!
lessFromInteger:anInteger
@@ -2394,7 +2397,7 @@
num := anInteger abs.
SmallInteger maxBytes == 8 ifTrue:[
- (num > 16r3FFFFFFF) ifTrue:[
+ (num > 16rFFFFFFFF) ifTrue:[
"if num is too big (so that multiplying by a byte could create a Large)"
^ anInteger retry:#* coercing:self
].
@@ -2598,12 +2601,12 @@
UINT64 _prod64;
__t = ((unsigned *)digitP)[0];
- digitP += 4;
_prod64 = (INT64)_v;
_prod64 *= __t;
_prod64 += _carry;
((unsigned *)resultP)[0] = _prod64 /* & 0xFFFFFFFFL */;
_carry = _prod64 >> 32;
+ digitP += 4;
resultP += 4;
_l -= 4;
}
@@ -2612,12 +2615,12 @@
UINT64 _prod64;
__t = ((unsigned short *)digitP)[0];
- digitP += 2;
_prod64 = (INT64)_v;
_prod64 *= __t;
_prod64 += _carry;
((unsigned short *)resultP)[0] = _prod64 /* & 0xFFFF */;
_carry = _prod64 >> 16;
+ digitP += 2;
resultP += 2;
_l -= 2;
}
@@ -4634,7 +4637,7 @@
/*
* two word-sized numbers, no carry - a very common case ...
*/
-#if defined(__LSB_FIRST__)
+#if defined(__LSBFIRST__)
unsigned INT _sum = *(unsigned INT *)_otherDigits + *(unsigned INT *)_myDigits;
#else
unsigned INT _sum = __unsignedLongIntVal(self) + __unsignedLongIntVal(aLargeInteger);
@@ -4668,7 +4671,7 @@
_carry = 0;
#if defined(__LSBFIRST__)
-# if (__POINTER_SIZE__ == 8) && defined(__GNUC__)
+# if (__POINTER_SIZE__ == 8) && defined(__GNUC__) && defined(__alpha__)
# if 0 /* not faster (on alpha) */
{
int _comLen7;
@@ -4701,11 +4704,11 @@
_index += 8;
}
}
-# endif
-# endif /* 64bit */
+# endif / notdef */
+# endif /* 64bit alpha */
# if (__POINTER_SIZE__ == 8)
-# if 0 /* not faster (on alpha) */
+# if 0 /* not faster */
{
int _comLen7;