Interval>>#includes: still buggy

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

Interval>>#includes: still buggy

Nicolas Cellier
Though my efforts to solve bugs related to Interval>>#includes:
implementation still is weak...
This weakness is due to the fact we desperately try to make the
inclusion test fuzzy when inexact Float representation is used...
Reading the code, I just realized that fuzzyness was not applied on
the interval range.

Thus it is easy to get surprising results:

(1.0 to: 3.0 predecessor by: 1.0 predecessor predecessor) includes: 3 asFloat.
is false while:
(1.0 to: 3.0 predecessor by: 1.0 predecessor predecessor) asArray ->
#(1.0 2.0 3.0).

OK, 3 asFloat is 1 ulp greater than the upper bound of the Interval,
so maybe we might take strict range checking as a rule...
But:

(1.0 to: 3.0 by: 1.0 successor) includes: 3 asFloat.
Is true while:
(1.0 to: 3.0 by: 1.0 successor) asArray -> #(1.0 2.0).

Oh, 3 asFloat is far far away from the upper bound this time, and we
pretend it is included... Not that logical, is it ?

My opinion still is to let Interval behave like super and not use fuzzyness.
Eventually, fuzzy inclusion could be implemented as a separate message.
Anyway, Interval of Float is IMHO not a pattern to encourage.

Nicolas