The Trunk: Kernel-spfa.1312.mcz

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

The Trunk: Kernel-spfa.1312.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-spfa.1312.mcz

==================== Summary ====================

Name: Kernel-spfa.1312
Author: spfa
Time: 8 March 2020, 2:22:41.860727 pm
UUID: 69693489-ed71-fa41-ad62-441618120c9c
Ancestors: Kernel-nice.1311

Make comparing two near-zero numbers follow the same logic as comparing a near-zero number and zero.

=============== Diff against Kernel-nice.1311 ===============

Item was changed:
  ----- Method: Float>>closeTo: (in category 'comparing') -----
  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: [
+ | abs |
+ (abs := self abs) < 0.0001 ifTrue: [^num abs < 0.0001].
+ (self - num) abs / (abs max: num abs) < 0.0001]!
- ^self = num asFloat
- or: [(self - num) abs / (self abs max: num abs) < 0.0001]!