Original code and complement code conversion

The complement of a positive number is its original code, except that the sign bit is always 0, that is:

真值:1, 原码:00000001B, 补码:00000001B

The complement of a negative number is the complement of its absolute value, invert each bit and add 1:

真值:-1, 绝对值:1, 绝对值补码:00000001B, 
补码=各位取反加 1 :11111110B+1B = 11111111B = ffH

The complement of the negative number is converted to the true value by inverting the complement and adding 1, and then adding a '-' minus sign:

真值:-1, 补码: 11111111B,各位取反加 1 添负号:-00000001B = -1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325636650&siteId=291194637
Recommended