29. Divide Two Integers

public class Solution {
    public int divide(int dividend, int divisor) {
        int sign=1;
        if((dividend>0&&divisor<0)||(dividend<0&&divisor>0)) sign=-1;
        long ldividend=Math.abs((long)dividend);
        long ldivisor=Math.abs((long)divisor);
        if(dividend==0||(ldividendInteger.MAX_VALUE){
            ans = (sign == 1)? Integer.MAX_VALUE : Integer.MIN_VALUE;
        }else ans=(int)(sign*lans);
        return ans;
    }
    private long ldivide(long ldividend,long ldivisor){
        if(ldividend

你可能感兴趣的:(29. Divide Two Integers)