classSolution(object):defdivide(self,dividend,divisor):""" :type dividend: int :type divisor: int :rtype: int """max=2147483647ifdivisor==0:returnmaxneg=(dividend<0anddivisor>0)or(dividend>0anddivisor<0)a=abs(dividend)b=abs(divisor)ret=0shift=31whileshift>=0:ifa>=(b<<shift):a-=b<<shiftret+=1<<shiftshift-=1ifneg:ret=-retifret>=max:returnmaxreturnret