Skip to content

Reduce chance of overflow panics on Midpoint Interpolate #27

Closed
@xd009642

Description

@xd009642

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 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions