semf
dividewithround.cpp
Go to the documentation of this file.
1
11
12namespace semf
13{
14intmax_t DivideWithRound::divide(intmax_t dividend, intmax_t divisor)
15{
16 intmax_t result = dividend / divisor;
17 if (((result + 1) * divisor - dividend) < (dividend - (result * divisor)))
18 {
19 result = result + 1;
20 }
21 return result;
22}
23} /* namespace semf */
static intmax_t divide(intmax_t dividend, intmax_t divisor)
Divides 2 integers with the right rounding.