public int divide(int a, int b) {
        int sign = 1; // Sign is positive by default
        int result = 0;

        if (b == 0)
            throw new IllegalArgumentException("The divisor can't be 0!");

        // Handle sign if a is negative
        if (a < 0) {
            a = -a;
            sign = -sign;
        }

        // Handle sign if b is negative
        if (b < 0) {
            b = -b;
            sign = -sign;
        }


        while (a >= 0) {
            a -= b;
            result++;
        }

        return sign * (result - 1);
    }