1

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 floats. Trying to do div(0.4, 0.8) gives the compiler error:

'div': ambiguous call to overloaded function

How can I use div for floats?

Jonathan Mee
  • 36,513
  • 20
  • 115
  • 270
A.Vasil
  • 37
  • 8

0 Answers0