Open bcliden opened 3 days ago
Hi @bcliden. Thanks for opening the issue and for clearly showing the expected behaviour.
This seems reasonable to me. Feel free to open up a PR with this change. @mitchmindtree do you remember what you were referencing when you ported this function originally?
Hello, I am writing some unit tests on nannou for a university course . I found that
fmod
has some slight differences compared to the C/C++ implementation. These specific examples are from the cppreference page on fmod.C/C++ (tested with gcc 14.2.1 on fedora)
nannou math::fmod
As you can see, tests 2 and 3 are different. I believe this is due to the usage of
floor
(lower integer) rather thantruncate
(integer towards zero). The man page for fmod includes the following description:So I believe using
trunc()
here is the correct move if we want to be close to the C implementation. Using trunc results in the expected results (see Rust Playground here)If the project agrees, I'd like to submit a PR and unit tests for this change. Thanks!