Is there any ceil
counterpart for Math.floorDiv()
How to calculate it fastest way with what we have?
UPDATE
The code for floorDiv()
is follows:
public static long floorDiv(long x, long y) {
long r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
}
Can we code ceil
the similar way?
UPDATE 2
I saw this answer https://stackoverflow.com/a/7446742/258483 but it seems to have too many unnecessary operations.