integerPart and fractionPart fixed for negative numbers
authorClaus Gittinger <cg@exept.de>
Mon, 05 Nov 2001 18:48:08 +0100
changeset 6153 e92766db42c6
parent 6152 b987f345234e
child 6154 6cb999c5ace3
integerPart and fractionPart fixed for negative numbers
Fraction.st
--- a/Fraction.st	Mon Nov 05 18:02:13 2001 +0100
+++ b/Fraction.st	Mon Nov 05 18:48:08 2001 +0100
@@ -719,37 +719,39 @@
 fractionPart
     "extract the after-decimal fraction part."
 
-    numerator < denominator ifTrue:[
+    numerator abs < denominator abs ifTrue:[
         ^ self
     ].
     ^ super fractionPart
 
     "
      (3/2) fractionPart 
+     (-3/2) fractionPart     
      (2/3) fractionPart 
      ((3/2)*(15/4)) fractionPart   
      ((2/3)*(4/15)) fractionPart   
     "
 
-    "Modified: / 28.10.1998 / 17:15:11 / cg"
+    "Modified: / 5.11.2001 / 17:55:25 / cg"
 !
 
 integerPart
     "extract the pre-decimal integer part."
 
-    numerator < denominator ifTrue:[
+    numerator abs < denominator abs ifTrue:[
         ^ 0
     ].
     ^ super integerPart
 
     "
-     (3/2) integerPart       
+     (3/2) integerPart        
+     (-3/2) integerPart        
      (2/3) integerPart           
      ((3/2)*(15/4)) integerPart   
      ((2/3)*(4/15)) integerPart   
     "
 
-    "Modified: / 28.10.1998 / 17:16:10 / cg"
+    "Modified: / 5.11.2001 / 17:55:01 / cg"
 !
 
 rounded
@@ -796,6 +798,6 @@
 !Fraction class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.52 2001-10-02 09:58:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.53 2001-11-05 17:48:08 cg Exp $'
 ! !
 Fraction initialize!