avoid an extra compare when multiplying into a largeInteger.
authorClaus Gittinger <cg@exept.de>
Thu, 20 Mar 1997 21:16:45 +0100
changeset 2470 44b8dddd5842
parent 2469 ecca86d50852
child 2471 035dbf8db9f3
avoid an extra compare when multiplying into a largeInteger.
SmallInt.st
SmallInteger.st
--- a/SmallInt.st	Thu Mar 20 20:37:19 1997 +0100
+++ b/SmallInt.st	Thu Mar 20 21:16:45 1997 +0100
@@ -193,22 +193,22 @@
 		RETURN ( __MKSMALLINT((int)product) );
 	    }
 	    if (product < 0) {
-		negative = 1;
+		negative = -1;
 		product = -product;
 	    } else {
-		negative = 0;
+		negative = 1;
 	    }
 	    productHi = product >> 32;
 	    productLow = product & 0xFFFFFFFF;
 	}
 #else
-	negative = 0;
+	negative = 1;
 	if (myValue < 0) {
-	    negative = 1;
+	    negative = -1;
 	    myValue = -myValue;
 	}
 	if (otherValue < 0) {
-	    negative = (1 - negative);
+	    negative = -negative;
 	    otherValue = -otherValue;
 	}
 
@@ -253,7 +253,7 @@
 	    if ((pHL == 0)
 	     && (pLH == 0)
 	     && ((pLL & 0xC0000000) == 0)) {
-		if (negative) {
+		if (negative < 0) {
 		    RETURN ( __MKSMALLINT(- ((INT)pLL)) );
 		}
 		RETURN ( __MKSMALLINT((INT)pLL) );
@@ -275,7 +275,7 @@
 #  endif
 # endif
 	if (productHi == 0) {
-	    if (negative) {
+	    if (negative < 0) {
 		if (productLow <= -(_MIN_INT)) {
 		    RETURN ( __MKSMALLINT(-((INT)productLow)) );
 		}
@@ -290,7 +290,7 @@
 	{
 	    extern OBJ __MKLARGEINT64();
 
-	    RETURN (__MKLARGEINT64(negative ? -1 : 1, productLow, productHi));
+	    RETURN (__MKLARGEINT64(negative, productLow, productHi));
 	}
     } else if (__isFloatLike(aNumber)) {
 	OBJ newFloat;
@@ -2348,5 +2348,5 @@
 !SmallInteger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SmallInt.st,v 1.69 1997-03-01 16:02:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/SmallInt.st,v 1.70 1997-03-20 20:16:45 cg Exp $'
 ! !
--- a/SmallInteger.st	Thu Mar 20 20:37:19 1997 +0100
+++ b/SmallInteger.st	Thu Mar 20 21:16:45 1997 +0100
@@ -193,22 +193,22 @@
 		RETURN ( __MKSMALLINT((int)product) );
 	    }
 	    if (product < 0) {
-		negative = 1;
+		negative = -1;
 		product = -product;
 	    } else {
-		negative = 0;
+		negative = 1;
 	    }
 	    productHi = product >> 32;
 	    productLow = product & 0xFFFFFFFF;
 	}
 #else
-	negative = 0;
+	negative = 1;
 	if (myValue < 0) {
-	    negative = 1;
+	    negative = -1;
 	    myValue = -myValue;
 	}
 	if (otherValue < 0) {
-	    negative = (1 - negative);
+	    negative = -negative;
 	    otherValue = -otherValue;
 	}
 
@@ -253,7 +253,7 @@
 	    if ((pHL == 0)
 	     && (pLH == 0)
 	     && ((pLL & 0xC0000000) == 0)) {
-		if (negative) {
+		if (negative < 0) {
 		    RETURN ( __MKSMALLINT(- ((INT)pLL)) );
 		}
 		RETURN ( __MKSMALLINT((INT)pLL) );
@@ -275,7 +275,7 @@
 #  endif
 # endif
 	if (productHi == 0) {
-	    if (negative) {
+	    if (negative < 0) {
 		if (productLow <= -(_MIN_INT)) {
 		    RETURN ( __MKSMALLINT(-((INT)productLow)) );
 		}
@@ -290,7 +290,7 @@
 	{
 	    extern OBJ __MKLARGEINT64();
 
-	    RETURN (__MKLARGEINT64(negative ? -1 : 1, productLow, productHi));
+	    RETURN (__MKLARGEINT64(negative, productLow, productHi));
 	}
     } else if (__isFloatLike(aNumber)) {
 	OBJ newFloat;
@@ -2348,5 +2348,5 @@
 !SmallInteger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.69 1997-03-01 16:02:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.70 1997-03-20 20:16:45 cg Exp $'
 ! !