def to_twos_comp(val, bits):
if not val.startswith('<STR_LIT:->'):<EOL><INDENT>return to_int(val)<EOL><DEDENT>value = _invert(to_bin_str_from_int_string(bits, bin(to_int(val[<NUM_LIT:1>:]))))<EOL>return int(value, <NUM_LIT:2>) + <NUM_LIT:1><EOL>
compute the 2's compliment of int value val