```
def divide(self, a, b):
isPositive, a, b, result = (a >= 0) ^ (b < 0), abs(a), abs(b), 0
while a >= b:
n, nb = 1, b
while a >= nb:
a, result = a - nb, result + n
n, nb = n << 1, nb << 1
return min(result, 2147483647) if isPositive else max(-result, -2147483648)
```