--- a/Float.st Mon Nov 05 16:32:32 2001 +0100
+++ b/Float.st Mon Nov 05 16:34:06 2001 +0100
@@ -566,6 +566,29 @@
^ true "/ this may be a lie
! !
+!Float methodsFor:'Compatibility - Squeak'!
+
+closeTo: num
+ "are these two numbers close?"
+ | fuzz ans |
+ num isNumber ifFalse: [
+ [ans:=self = num] ifError: [:aString :aReceiver | ^ false].
+ ^ ans].
+ self = 0.0 ifTrue: [^ num abs < 0.0001].
+ num = 0.0 ifTrue: [^ self abs < 0.0001].
+ self isNaN == num isNaN ifFalse: [^ false].
+ self isInfinite == num isInfinite ifFalse: [^ false].
+
+ fuzz := (self abs max: num abs) * 0.0001.
+ ^ (self - num) abs <= fuzz
+
+
+ "9.0 closeTo: 8.9999
+ 9.9 closeTo: 9
+ (9/3) closeTo: 2.9999
+ "
+! !
+
!Float methodsFor:'arithmetic'!
* aNumber
@@ -2155,6 +2178,6 @@
!Float class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.118 2001-10-02 09:58:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Float.st,v 1.119 2001-11-05 15:34:06 james Exp $'
! !
Float initialize!