PackageDescription: SYSBUG-FloatIntervalTest


SYSBUG - Float Interval Test

Last published: June 27, 2008 by 'nice'

Defines 1 Classes
Extends 1 Classes


The Compiler optimized to:do: loop is not consistent with Interval>>do:
The former does
value := value + step
While the later does
value := start + (index*step)

Thus, we can exploit this to show how optimization changes the results:

| eps count |
eps := 1.0d0 timesTwoPower: -52.
count := 0.
1 + eps to: 2 do: [:x | count := count + 1].
(1 + eps to: 2) do: [:x | count := count - 1].
^count

result in a non null count.

Agree, Floating Point Interval are bad habit, and bug is minor, but...

Nicolas

---------------------------------

Try:

(1 to: 3) = #(1 2 3).
(1 to: 3) hash = #(1 2 3) hash.

What did mother Smalltalk teach about equal and hash?

Try also this one:

(2 to: 1) first.
(2 to: 1) last.

This mathematically proves that an empty Interval is not empty.

The problem is that Interval are used with two uncompatible semantics:
- one as collection of Numbers
- the other as Text selection range

Last detail, VW let me create (1 to: 10 by: 0).
Well nothing wrong about that, except that error will be delayed until interval is used. My experience is that it's always better to open the debugger on the real originator rather than on an indirect consequence.