```
public class Solution {
public int Divide(int dividend, int divisor) {
long de = Math.Abs((long)dividend);
long dr = Math.Abs((long)divisor);
long trial = dr;
long unsignedans = 1;
while (de - trial > 0) {
trial = trial << 1;
unsignedans = unsignedans << 1;
}
while (de - trial < 0) {
trial -= dr;
unsignedans--;
}
var ans = dividend > 0 ^ divisor > 0 ? -unsignedans : unsignedans;
if (ans > int.MaxValue) return int.MaxValue;
return (int) ans;
}
}
```