Nov. 26, 2010
3:33 p.m.
Comment #2 on issue 3329 by alexandre.bergel: Object>>closeTo: http://code.google.com/p/pharo/issues/detail?id=3329 Yeah, I agree. But it is essentially interesting for Float: Float>>closeTo: num "are these two numbers close?" num isNumber ifFalse: [^[self = num] ifError: [false]]. self = 0.0 ifTrue: [^num abs < 0.0001]. num = 0 ifTrue: [^self abs < 0.0001]. ^self = num asFloat or: [(self - num) abs / (self abs max: num abs) < 0.0001] The problem is that you can two float which are the same, but have a different internal representation. But still, having closeTo: on Object does not make sense. Does it make sense to be able to do 'abc' closeTo: 'abc' ?