Intervals
David N. Smith (IBM)
dnsmith at watson.ibm.com
Mon Nov 29 23:42:11 UTC 1999
At 13:14 -0500 11/29/99, Jarvis, Robert P. wrote:
>The attached change set combines Andrew's changes with Dan's suggestions and
>runs correctly for the test cases identified, as well as for negative
>numbers, i.e.
Hummmm... I've been looking at the code and I wonder if it will
always work with floating point values? Stepping through the interval
involves adding the step value at each increment, but asking if a
value is in the interval involves modulo arithmetic. The problem
comes when the step value cannot be exactly represented in binary
(0.7 for example).
I can't believe it will always work identically, but I've not been
able to come up with a test case that fails. (I implemented a version
if #includes: that is simply:
includesP: aValue
^ self asArray includes: aValue
and used it for comparison. This IS a precise and accurate solution,
though it might run out of memory at inconvenient times and otherwise
misbehave when the interval has lots of elements.
Dave
_______________________________
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.
More information about the Squeak-dev
mailing list
|