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

array_round() #4

Open
ma-laforge opened this issue May 8, 2021 · 0 comments
Open

array_round() #4

ma-laforge opened this issue May 8, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ma-laforge
Copy link
Owner

Much of the initial code would implicitly round array indices (or similar Int-only values) in from floating point representations.

@ma-laforge was not 100% sure what happened in the original execution, so the rounding was wrapped into a call to
array_round(i) = round(Int, i). It is not certain if this function correctly reproduces the original behaviour.

Either way, these calls should be replaced with explicit rounding functions, for example:

  • x[1:div(n,2)] instead of x[1:(n/2)] - Well, unless the original code expected rounding up.
  • x[1:round(Int, float_idx)]
  • x[1:floor(Int, float_idx)]
  • x[1:ceil(Int, float_idx)]

Unfortunately, the original author's intent for rounding is not always easy to decipher.

Floating-point order

There were other cases where order was passed around as a floating point value (potentially having a 0.5 fractional value after dividing by 2).

Goal

The original intent should be resolved so that floating point representations are eliminated. As a side benefit, this should also reduce accidental errors introduced when modifying code in the future.

@ma-laforge ma-laforge added the bug Something isn't working label May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant