Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Iterator's double range more consistent #1309

Closed
l0rinc opened this issue Apr 28, 2016 · 1 comment
Closed

Make Iterator's double range more consistent #1309

l0rinc opened this issue Apr 28, 2016 · 1 comment

Comments

@l0rinc
Copy link
Contributor

l0rinc commented Apr 28, 2016

Currently double range iteration can stop before the end, if consecutive numbers have a greater distance than the step size.

Two simple possible fixes came up:

  • increment by either step size or the smallest possible step, considering the floating point representation (done in the current PR)
  • Scala seems to use BigDecimal under the hood. This is somewhat slower and will result in consecutive values that are equal to each other.

Note: it's unlikely that many people will create ranges with infinity or where the step size is smaller than an ULP.

@danieldietrich
Copy link
Contributor

Stopping before end can be considered as bug. I will change the label of this issue accordingly.

I think Scala's approach is the best. It is performing the calculation exactly in the manner as expected and projects the result into the space of doubles. This is the best we can do.

It is like a 3d rendering scene projected on a 2d display. There's a loss of information but our brain interprets it as correct when looking at the pixels. If we would change the algorithm (linear transformation of vector matrices), we could fit the pixel space better but the visual perspective is not natural any more and our brain will interpret the rendered scene as wrong.

Interpolation of the real world is the way to go, not changing how the real world behaves.

@danieldietrich danieldietrich modified the milestones: 2.0.5, 2.1.0 Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants