def bit_not_op(v,bit_size): bit16_not_val = 0 for i in range(0,bit_size): if ((v >> i)&0x1) == 0 : bit16_not_val |= (1 << i) return (bit16_not_val)
# 有符号的16位整数
v_offset = ((v1 << 8) | (v0 << 0)) hight_bit = (v_offset >> 15) & 1 if hight_bit : v_offset = bit_not_op(v_offset,16) v_offset = v_offset + 1 v_offset = - (v_offset & 0x7FFF)