#compareSafely: and complex numbers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

#compareSafely: and complex numbers

Christoph Thiede

Hi all,


I just found out that the following throws a DNU:


1 compareSafely: 1 i.


It is mathematically correct that Complex does not implement #<. However, why does Complex override #isNumber to return true? Where is this used?

Should we maybe check in Number>>#compareSafely: whether aNumber respondsTo: #<? Or introduce something like #isMagnitude?


Number>>compareSafely: aNumber 

^ (aNumber isNumber and: [aNumber isMagnitude])
ifTrue: [ self < aNumber ]
ifFalse: [ super compareSafely: aNumber ]


Best,

Christoph



Carpe Squeak!