Skip to content

Reduce chance of overflow panics on Midpoint Interpolate #27

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

Closed
xd009642 opened this issue Feb 24, 2019 · 1 comment
Closed

Reduce chance of overflow panics on Midpoint Interpolate #27

xd009642 opened this issue Feb 24, 2019 · 1 comment
Labels
Bug Something isn't working

Comments

@xd009642
Copy link
Collaborator

Midpoint interpolate is currently implemented like:

let denom = T::from_u8(2).unwrap();
(lower.unwrap() + higher.unwrap()).mapv_into(|x| x / denom.clone())

This causes overflows most times I use it, whereas implementing like (lower + (higher - lower))/2 would prevent this.

Also, happy to do a PR for this if it would be helpful but I figured it was such a small change it might be quicker if you guys sorted it yourselves 👍

@LukeMathWalker LukeMathWalker added the Bug Something isn't working label Feb 24, 2019
@xd009642
Copy link
Collaborator Author

I see the fix has been merged so I'll close this issue 👍

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

2 participants