--- a/Fraction.st Tue Oct 02 10:15:17 2001 +0200
+++ b/Fraction.st Tue Oct 02 11:58:53 2001 +0200
@@ -180,6 +180,16 @@
|n d|
+ "/
+ "/ notice:
+ "/ the following code handles some common cases,
+ "/ and exists as an optimization, to speed up those cases.
+ "/
+ "/ Conceptionally, (and for most other argument types),
+ "/ mixed arithmetic is implemented by double dispatching
+ "/ (see the message send at the bottom)
+ "/
+
(aNumber isMemberOf:SmallInteger) ifTrue:[
^ (self class numerator:(numerator * aNumber)
denominator:denominator)
@@ -194,6 +204,7 @@
(aNumber isMemberOf:Float) ifTrue:[
^ (numerator * aNumber) / denominator
].
+
^ aNumber productFromFraction:self
"Modified: 28.7.1997 / 19:09:23 / cg"
@@ -204,6 +215,16 @@
|n d|
+ "/
+ "/ notice:
+ "/ the following code handles some common cases,
+ "/ and exists as an optimization, to speed up those cases.
+ "/
+ "/ Conceptionally, (and for most other argument types),
+ "/ mixed arithmetic is implemented by double dispatching
+ "/ (see the message send at the bottom)
+ "/
+
(aNumber isMemberOf:SmallInteger) ifTrue:[
^ (self class numerator:(numerator + (denominator * aNumber))
denominator:denominator)
@@ -226,6 +247,7 @@
(aNumber isMemberOf:Float) ifTrue:[
^ aNumber + (numerator asFloat / denominator asFloat)
].
+
^ aNumber sumFromFraction:self
"Modified: 28.7.1997 / 19:09:16 / cg"
@@ -236,6 +258,16 @@
|n d|
+ "/
+ "/ notice:
+ "/ the following code handles some common cases,
+ "/ and exists as an optimization, to speed up those cases.
+ "/
+ "/ Conceptionally, (and for most other argument types),
+ "/ mixed arithmetic is implemented by double dispatching
+ "/ (see the message send at the bottom)
+ "/
+
(aNumber isMemberOf:SmallInteger) ifTrue:[
^ (self class numerator:(numerator - (denominator * aNumber))
denominator:denominator)
@@ -258,6 +290,7 @@
(aNumber isMemberOf:Float) ifTrue:[
^ (numerator asFloat / denominator asFloat) - aNumber
].
+
^ aNumber differenceFromFraction:self
"
@@ -276,6 +309,16 @@
|n d|
+ "/
+ "/ notice:
+ "/ the following code handles some common cases,
+ "/ and exists as an optimization, to speed up those cases.
+ "/
+ "/ Conceptionally, (and for most other argument types),
+ "/ mixed arithmetic is implemented by double dispatching
+ "/ (see the message send at the bottom)
+ "/
+
(aNumber isMemberOf:SmallInteger) ifTrue:[
^ (self class numerator:numerator
denominator:(denominator * aNumber))
@@ -290,6 +333,7 @@
(aNumber isMemberOf:Float) ifTrue:[
^ numerator / (denominator * aNumber)
].
+
^ aNumber quotientFromFraction:self
"Modified: 28.7.1997 / 19:09:06 / cg"
@@ -752,6 +796,6 @@
!Fraction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.51 2001-10-02 08:15:03 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.52 2001-10-02 09:58:53 cg Exp $'
! !
Fraction initialize!