Align nannou_core::math::fmod with C behavior #984
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
This PR addresses the minor inconsistency that I brought up in issue #983 (see for more context). In short, during the fmod calculation, truncating (moving towards 0) is more accurate to the original
fmod
function from C.I do have a few small notes/questions:
float_eq
crate as a dev dependency in order to assert against the float values. Is that okay or would you prefer a test assertion that doesn't pull in a dependency? I can hand roll a delta check (or similar) if we would prefer that.math.rs
file. I didn't see a strong standard elsewhere in the project. Is this okay or would a doctest or a package-level test (nannou_core/tests/*
maybe) be preferable?Thanks for the opportunity to contribute to the project. Please let me know if there's anything I can update in this PR, I'm happy to do so.