At 14:04 -0600 11/30/99, Michael Donegan wrote:
Aren't floats fun! :-)
No kidding. The introduction of floats causes a problem because there is no unified notion of float comparison in Smalltalk.
It is *not* a Smalltalk problem. There is no way to compare floats for equality that does not fail because of base conversion or computational error problems.
It's one of the basic rules of nature:
Never compare two floats for equality.
It right up there with "Don't tug on Superman's cape".
Some languages have introduced the concept of ~fuzz~ for comparisons, but that IMHO is simply a way to encourage people to use floats without understanding them.
Besides, how big is the ~fuzz~? Would it allow intervals like this to work?
(1.0e-200 to: 5.0e-200 by: 0.5e-200)
or would a ~fuzz~ of 1.0e-15 overwhelm the #to: value in the interval? Would it solve problems when the exponents are huge:
(1.0e200 to: 5.0e200 by 0.5e200)
In comparison to 1.0e200, a fixed fuzz value of 1.0e-15 or whatever makes no difference at all.
Floats have a wide range for exponents on purpose; they do get used. If you want the diameter of an electron in centimeters you don't do it without very small exponents. If you want the diameter of the universe in meters you don't do it without very large exponents.
Note that FORTRAN, the most widely used scientific and engineering programming language (80% or more of the market) does not have ~fuzz~. There is no reason why Smalltalk needs it either.
Dave
(BTW, ~fuzz~ is simply a way to make the word fuzz look fuzzy?) _______________________________ David N. Smith IBM T J Watson Research Center Hawthorne, NY _______________________________ Any opinions or recommendations herein are those of the author and not of his employer.