Fraction.st
changeset 15278 ddf05cd996da
parent 13357 487c502b40b7
child 16729 0cf2bfd45072
child 18062 014678b4657a
--- a/Fraction.st	Mon May 27 10:14:16 2013 +0200
+++ b/Fraction.st	Mon May 27 10:14:32 2013 +0200
@@ -526,7 +526,8 @@
 !
 
 asLongFloat
-    "return a long float with (approximately) my value"
+    "return a long float with (approximately) my value.
+     Since floats have a limited precision, you usually loose bits when doing this."
 
     |num den numShift denShift numBits rslt|
 
@@ -539,19 +540,11 @@
     numBits := LongFloat precision * 2.    "number of bits to preserve (conservative)"
     num := numerator abs.
     numShift := numBits - num highBit. "(num highBit - bits) negated"
-    numShift < 0 ifTrue:[
-        num := num bitShift:numShift
-    ] ifFalse:[
-        numShift := 0
-    ].
+    numShift < 0 ifTrue:[num := num bitShift:numShift] ifFalse:[ numShift := 0].
 
     den :=  denominator.
     denShift := numBits - den highBit. "(den highBit - bits) negated"
-    denShift < 0 ifTrue:[
-        den := den bitShift:denShift
-    ] ifFalse:[
-        denShift := 0
-    ].
+    denShift < 0 ifTrue:[den := den bitShift:denShift] ifFalse:[denShift := 0].
 
     rslt := (num asLongFloat / den asLongFloat) * (2 raisedToInteger:denShift-numShift).
     numerator negative ifTrue:[ ^ rslt negated ].
@@ -1158,11 +1151,12 @@
 !Fraction class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.81 2011-05-03 09:08:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.82 2013-05-27 08:14:32 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.81 2011-05-03 09:08:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.82 2013-05-27 08:14:32 cg Exp $'
 ! !
 
+
 Fraction initialize!