--- a/LargeInt.st Fri May 08 00:26:37 1998 +0200
+++ b/LargeInt.st Fri May 08 01:34:37 1998 +0200
@@ -590,18 +590,24 @@
sign == 1 ifTrue:[
sz := digitByteArray size.
%{
- if (__intVal(sz) == sizeof(INT)) {
- unsigned char *bp;
-
- bp = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray)));
- if ((bp[sizeof(INT)-1] == 0x40)
- && (bp[sizeof(INT)-2] == 0)
- && (bp[sizeof(INT)-3] == 0)
+ int idx;
+ unsigned char *bp;
+
+ bp = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray))->ba_element);
+ idx = __intVal(sz);
+
+ while ((idx > 1) && (bp[idx-1] == 0)) idx--;
+ if (idx == sizeof(INT)) {
+
+ if ((bp[idx-1] == 0x40)
+ && (bp[idx-2] == 0)
+ && (bp[idx-3] == 0)
+ && (bp[idx-4] == 0)
#ifdef alpha64
- && (bp[sizeof(INT)-4] == 0)
- && (bp[sizeof(INT)-5] == 0)
- && (bp[sizeof(INT)-6] == 0)
- && (bp[sizeof(INT)-7] == 0)
+ && (bp[idx-5] == 0)
+ && (bp[idx-6] == 0)
+ && (bp[idx-7] == 0)
+ && (bp[idx-8] == 0)
#endif
) {
RETURN (__MKSMALLINT(_MIN_INT));
@@ -1197,14 +1203,14 @@
the receiver"
(aNumber class == self class) ifFalse:[
- "/
- "/ 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)
- "/
- aNumber class == SmallInteger ifTrue:[^ false ].
- aNumber respondsToArithmetic ifFalse:[ ^ false ].
- ^ self retry:#= coercing:aNumber
+ "/
+ "/ 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)
+ "/
+ aNumber class == SmallInteger ifTrue:[^ false ].
+ aNumber respondsToArithmetic ifFalse:[ ^ false ].
+ ^ self retry:#= coercing:aNumber
].
(aNumber sign == sign) ifFalse:[^ false].
^ self absEq:aNumber
@@ -2595,5 +2601,5 @@
!LargeInteger class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/LargeInt.st,v 1.65 1998-02-24 17:27:29 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/LargeInt.st,v 1.66 1998-05-07 23:34:37 cg Exp $'
! !
--- a/LargeInteger.st Fri May 08 00:26:37 1998 +0200
+++ b/LargeInteger.st Fri May 08 01:34:37 1998 +0200
@@ -590,18 +590,24 @@
sign == 1 ifTrue:[
sz := digitByteArray size.
%{
- if (__intVal(sz) == sizeof(INT)) {
- unsigned char *bp;
-
- bp = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray)));
- if ((bp[sizeof(INT)-1] == 0x40)
- && (bp[sizeof(INT)-2] == 0)
- && (bp[sizeof(INT)-3] == 0)
+ int idx;
+ unsigned char *bp;
+
+ bp = (unsigned char *)(__ByteArrayInstPtr(__INST(digitByteArray))->ba_element);
+ idx = __intVal(sz);
+
+ while ((idx > 1) && (bp[idx-1] == 0)) idx--;
+ if (idx == sizeof(INT)) {
+
+ if ((bp[idx-1] == 0x40)
+ && (bp[idx-2] == 0)
+ && (bp[idx-3] == 0)
+ && (bp[idx-4] == 0)
#ifdef alpha64
- && (bp[sizeof(INT)-4] == 0)
- && (bp[sizeof(INT)-5] == 0)
- && (bp[sizeof(INT)-6] == 0)
- && (bp[sizeof(INT)-7] == 0)
+ && (bp[idx-5] == 0)
+ && (bp[idx-6] == 0)
+ && (bp[idx-7] == 0)
+ && (bp[idx-8] == 0)
#endif
) {
RETURN (__MKSMALLINT(_MIN_INT));
@@ -1197,14 +1203,14 @@
the receiver"
(aNumber class == self class) ifFalse:[
- "/
- "/ 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)
- "/
- aNumber class == SmallInteger ifTrue:[^ false ].
- aNumber respondsToArithmetic ifFalse:[ ^ false ].
- ^ self retry:#= coercing:aNumber
+ "/
+ "/ 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)
+ "/
+ aNumber class == SmallInteger ifTrue:[^ false ].
+ aNumber respondsToArithmetic ifFalse:[ ^ false ].
+ ^ self retry:#= coercing:aNumber
].
(aNumber sign == sign) ifFalse:[^ false].
^ self absEq:aNumber
@@ -2595,5 +2601,5 @@
!LargeInteger class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.65 1998-02-24 17:27:29 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/LargeInteger.st,v 1.66 1998-05-07 23:34:37 cg Exp $'
! !