def twos_comp(self, val, bits):
if (val & (<NUM_LIT:1> << (bits - <NUM_LIT:1>))) != <NUM_LIT:0>:  <EOL><INDENT>val = val - (<NUM_LIT:1> << bits)  <EOL><DEDENT>return val<EOL>
two complement to get negative
:param val:
:param bits: