Maybe the case -2147483648 should be taken care of alone?

```
class Solution {
public:
int divide(int dividend, int divisor) {
long long ans = 0;
bool minus = (dividend > 0) ^ (divisor > 0);
long long dividend1 = abs((long long) dividend);
long long divisor1 = abs((long long) divisor);
while ((dividend1 - divisor1) >= 0) {
long long x = divisor1;
long long t = 1;
while (x + x <= dividend1) {
x += x;
t += t;
}
dividend1 -= x;
ans += t;
}
if (minus)
ans = -ans;
if (ans > 2147483647) {
ans = 2147483647;
}
return (int) ans;
}
};
```