get sign of result
let sign = ( dy < 0 ) ^ ( dx < 0 ) ; if ( sign ) { return [ Math . floor ( - Math . abs ( dy ) / g ) , Math . floor ( Math . abs ( dx ) / g ) ] ; } else return [ Math . floor ( Math . abs ( dy ) / g ) , Math . floor ( Math . abs ( dx ) / g ) ] ; }