2 ms·
Side question: what is the common behavior for mod on floating point? I have used it on integers plenty of times of course but not come across a situation where
by ineedasername 5y ago
Side question: what is the common behavior for mod on floating point? I have used it on integers plenty of times of course but not come across a situation where I would need similar behavior for floats. Is there something that's part of typical language's standard libraries or do you roll your own if you need it?
- MauranKilom 5y agoSee std::fmod and std::remainer: https://en.cppreference.com/w/cpp/numeric/math/fmod https://en.cppreference.com/w/cpp/numeric/math/fmod https://en.cppreference.com/w/cpp/numeric/math/remainder https://en.cppreference.com/w/cpp/numeric/math/remainder A valid use may be when approximating a periodic function via a polynomial (e.g. sin/cos), where you will want to first perform range reduction like std::fmod(x, 2 * pi).