pharo icon indicating copy to clipboard operation
pharo copied to clipboard

Interval size error with Floating Point step

Open rjsargent opened this issue 4 months ago • 1 comments

Pharo v9 through v12 overstates the size of (-4 to: 4 by: 0.1) Bug description Since 0.1 is not exactly represented in FP, we should see only 80 elements in that interval. But, #size calculates as 81 rather than 80.

To Reproduce | elements | elements := OrderedCollection new. -4 to: 4 by: 0.1 do: [ :i | elements add: i]. elements size 80

| elements | elements := OrderedCollection new. (-4 to: 4 by: 0.1) do: [ :i | elements add: i]. elements size 81

Expected behavior #do: should enumerate the same 80 elements that #to:by:do: does.

Screenshots If applicable, add screenshots to help explain your problem.

Version information:

  • OS: Windows
  • Version: 10 Pro
  • Pharo Version: 9 through 12, at least

Expected development cost Expected to be small

rjsargent avatar Oct 17 '24 20:10 rjsargent