pharo
pharo copied to clipboard
Interval size error with Floating Point step
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