Super simple and easy to understand binary original code, inverse code, complement code

Take 123 and -123 for example:

[123] Original code: 01111011. Inverse code: 01111011. Complement code: 01111011.

[-123] Original code: 11111011. Inverse code: 10000100. Complement: 10000101.

The original code, inverse code, and complement code of positive numbers are all equal.

Negative code calculation method:

        1. The sign bit remains unchanged.

        2. The other bits are negated.


Negative complement method:

        1. The sign bit remains unchanged.

        2. The other bits are negated.

        3. Add 1 to the last digit.

Guess you like

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