Ken,

At least it is non-ambiguous from a mathematical perspective, though I am still 
curious why this is so important to you - there might be a better solution to 
your problem.  I would replace #= with #closeTo:.  Float>>= runs through 
#asTrueFraction, which yields a rational but can still miss.

Speaking of #closeTo:, the tolerances look a little wide to me at first glance; 
it deserves a careful look.


Bill


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Ken.Dickey
Sent: Wednesday, August 12, 2009 7:40 PM
To: [email protected]
Subject: [Pharo-project] #< if at first you dont succeed..

OK, here is a strict version.  Complex>>< only compares numbers on the real or 
imaginal axis and throws an "incomparable" error otherwise.  The 
ComplexTest>>textCompare checks obvious cases.

Is this version (more) acceptable?

As usual, please feel free to correct (or send me corrections) for better 
coding style (e.g a shorter/better error message) as well as any dumbness on 
my part.

Cheers,
-KenD
------------------------Complex
< other
        "Can only compare with pure real or imaginary parts"
        ((self imaginary = 0) and: [other imaginary = 0])
        ifTrue: [^ self real < other real]
        ifFalse: [((self real = 0) and: [other real = 0])
                ifTrue: [^self imaginary < other imaginary]
                ifFalse: [ArithmeticError new 
                        signal: 'Complex numbers are not generally comparable'.]
                ]
------------------------

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to