Calculate sign of divisor i . e . , sign will be negative only iff either one of them is negative otherwise it will be positive
var sign = ( ( dividend < 0 ) ? 1 : 0 ^ ( divisor < 0 ) ? 1 : 0 ) ? - 1 : 1 ;