ArithmeticValue.st
changeset 7355 96f466eeddf5
parent 7228 b7c66af018f8
child 7378 e71a28f6b712
--- a/ArithmeticValue.st	Fri Jun 13 20:52:21 2003 +0200
+++ b/ArithmeticValue.st	Mon Jun 16 11:14:59 2003 +0200
@@ -407,7 +407,10 @@
 asLongFloat
     "return a longFloat with same value"
 
-   ^ self subclassResponsibility
+   "WARNING: could loose precision here, if not redefined in concrete classes which
+    have more than float precision (i.e. LargeIntegers and Fractions)"
+
+   ^ self asFloat asLongFloat "/ subclassResponsibility
 
     "Modified: / 17.4.1996 / 12:21:35 / cg"
     "Created: / 7.9.2001 / 13:39:31 / cg"
@@ -522,6 +525,13 @@
 
 !ArithmeticValue methodsFor:'double dispatching'!
 
+differenceFromComplex:aComplex
+    "the receiver does not know how to subtract from a complex -
+     retry the operation by coercing to higher generality"
+
+    ^ aComplex retry:#- coercing:self
+!
+
 differenceFromFixedPoint:aFixedPoint
     "the receiver does not know how to subtract from a fixedPoint number -
      retry the operation by coercing to higher generality"
@@ -561,6 +571,55 @@
     "Created: 17.4.1996 / 12:33:16 / cg"
 !
 
+equalFromComplex:aComplex
+    "the receiver does not know how to compare to a complex number -
+     retry the operation by coercing to higher generality"
+
+    ^ aComplex retry:#= coercing:self
+!
+
+equalFromFixedPoint:aFixedPoint
+    "the receiver does not know how to compare to a fixed point -
+     retry the operation by coercing to higher generality"
+
+    ^ aFixedPoint retry:#= coercing:self
+!
+
+equalFromFloat:aFloat
+    "the receiver does not know how to compare to a float -
+     retry the operation by coercing to higher generality"
+
+    ^ aFloat retry:#= coercing:self
+!
+
+equalFromFraction:aFraction
+    "the receiver does not know how to compare to a fraction -
+     retry the operation by coercing to higher generality"
+
+    ^ aFraction retry:#= coercing:self
+!
+
+equalFromInteger:anInteger
+    "the receiver does not know how to compare to an integer -
+     retry the operation by coercing to higher generality"
+
+    ^ anInteger retry:#= coercing:self
+!
+
+equalFromLongFloat:aLongFloat
+    "the receiver does not know how to compare to a long float -
+     retry the operation by coercing to higher generality"
+
+    ^ aLongFloat retry:#= coercing:self
+!
+
+equalFromShortFloat:aShortFloat
+    "the receiver does not know how to compare to a short float -
+     retry the operation by coercing to higher generality"
+
+    ^ aShortFloat retry:#= coercing:self
+!
+
 lessFromFixedPoint:aFixedPoint
     "the receiver does not know how to compare to a fixedPoint number -
      retry the operation by coercing to higher generality"
@@ -600,6 +659,13 @@
     "Modified: 17.4.1996 / 12:33:33 / cg"
 !
 
+productFromComplex:aComplex
+    "the receiver does not know how to multiply a complex -
+     retry the operation by coercing to higher generality"
+
+    ^ aComplex retry:#* coercing:self
+!
+
 productFromFixedPoint:aFixedPoint
     "the receiver does not know how to multiply a fixed point number -
      retry the operation by coercing to higher generality"
@@ -639,6 +705,13 @@
     "Created: 17.4.1996 / 12:33:48 / cg"
 !
 
+quotientFromComplex:aComplex
+    "the receiver does not know how to divide a complex -
+     retry the operation by coercing to higher generality"
+
+    ^ aComplex retry:#/ coercing:self
+!
+
 quotientFromFixedPoint:aFixedPoint
     "the receiver does not know how to divide a fixed point number -
      retry the operation by coercing to higher generality"
@@ -678,6 +751,13 @@
     "Created: 17.4.1996 / 12:34:00 / cg"
 !
 
+sumFromComplex:aComplex
+    "the receiver does not know how to add a complex -
+     retry the operation by coercing to higher generality"
+
+    ^ aComplex retry:#+ coercing:self
+!
+
 sumFromFixedPoint:aFixedPoint
     "the receiver does not know how to add a fixed point number -
      retry the operation by coercing to higher generality"
@@ -887,7 +967,8 @@
 !
 
 isComplex
-    "Answer whether the receiver has an imaginary part"
+    "Answer whether the receiver has an imaginary part
+     (i.e. if it is a complex number). Always false here."
 
     ^ false
 
@@ -1036,7 +1117,7 @@
 !ArithmeticValue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.46 2003-04-23 17:09:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ArithmeticValue.st,v 1.47 2003-06-16 09:14:02 cg Exp $'
 ! !
 
 ArithmeticValue initialize!