I was wondering if a function like div
exists for float numbers in C++. If I need both the integral division result and the remainder, div
provides that:
For example:
const auto foo = div(5, 2);
const auto quot = foo.quot; // This will be 2
const auto rem = foo.rem; // This will be 1
But this doesn't work with float
s. Trying to do div(0.4, 0.8)
gives the compiler error:
'div': ambiguous call to overloaded function
How can I use div
for float
s?