For division by zero, return Integer.MAX_VALUE instead of 999999.