What represents Math.IEEERemainder(x,y) in C++?
Try the fmod function.
In the C++11 standard library, std::remainder(x,y)
, is now the equivalent function of C#'s Math.IEEERemainder(x,y)
in C++.
From: http://en.cppreference.com/w/cpp/numeric/math/remainder
Computes the IEEE remainder of the floating point division operation
x/y
The IEEE remainder is x–(round(x/y)*y)
Whereas, the fmod
remainder is x - trunc(x/y)*y
, which can lead to different answers such as was raised in this question: Why am I getting a different result from std::fmod and std::remainder
If you really want to get the IEEE-defined remainder, you need std::remainder(x,y)
(or define your own function if you can't use C++11)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With