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

spread function off by 1 in negative direction #42

Open
tmhglnd opened this issue Feb 22, 2025 · 0 comments
Open

spread function off by 1 in negative direction #42

tmhglnd opened this issue Feb 22, 2025 · 0 comments

Comments

@tmhglnd
Copy link
Owner

tmhglnd commented Feb 22, 2025

When using spread() or spreadFloat() to generate a list starting at 0 towards a negative value, the starting value in the output is not 0. For example:

console.log(Gen.spread(6, 0, -6))
//=> [-1, -2, -3, -4, -5, -6]

I need to check the algorithm behind the spread/spreadFloat functions how this can be improved for this specific range.

The output is correct when the spread starts at the negative value:

console.log(Gen.spread(6, -6, 0))
//=> [-6, -5, -4, -3, -2, -1]

The output of spreadInclusive also works correctly in the sense that it starts at the lowest value.

console.log(Gen.spreadInc(6, 0, -5))
//=> [0, -1, -2, -3, -4, -5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant