Use Math.ceil() and cast the result to int:
- This is still faster than to avoid doubles by using abs().
- The result is correct when working with negatives, because -0.999 will be rounded UP to 0
Example:
(int) Math.ceil((double)divident / divisor);
Use Math.ceil() and cast the result to int:
Example:
(int) Math.ceil((double)divident / divisor);