def sgt(computation: BaseComputation) -> None: """ Signed Greater Comparison """ left, right = map( unsigned_to_signed, computation.stack_pop(num_items=2, type_hint=constants.UINT256), ) if left > right: result = 1 else: result = 0 computation.stack_push(signed_to_unsigned(result))
def sgt(computation: BaseComputation) -> None: """ Signed Greater Comparison """ left, right = map( unsigned_to_signed, computation.stack_pop_ints(2), ) if left > right: result = 1 else: result = 0 computation.stack_push_int(signed_to_unsigned(result))
def smod(computation: BaseComputation) -> None: """ Signed Modulo """ value, mod = map( unsigned_to_signed, computation.stack_pop(num_items=2, type_hint=constants.UINT256), ) pos_or_neg = -1 if value < 0 else 1 if mod == 0: result = 0 else: result = (abs(value) % abs(mod) * pos_or_neg) & constants.UINT_256_MAX computation.stack_push(signed_to_unsigned(result))
def sdiv(computation: BaseComputation) -> None: """ Signed Division """ numerator, denominator = map( unsigned_to_signed, computation.stack_pop(num_items=2, type_hint=constants.UINT256), ) pos_or_neg = -1 if numerator * denominator < 0 else 1 if denominator == 0: result = 0 else: result = (pos_or_neg * (abs(numerator) // abs(denominator))) computation.stack_push(signed_to_unsigned(result))
def sdiv(computation: BaseComputation) -> None: """ Signed Division """ numerator, denominator = map( unsigned_to_signed, computation.stack_pop_ints(2), ) pos_or_neg = -1 if numerator * denominator < 0 else 1 if denominator == 0: result = 0 else: result = (pos_or_neg * (abs(numerator) // abs(denominator))) computation.stack_push_int(signed_to_unsigned(result))