当前位置:网站首页>How to understand that binary complement represents negative numbers

How to understand that binary complement represents negative numbers

2022-07-07 15:38:00 sgmcy

First , If it means a positive number

that N position , The maximum positive number expressed is 2^N -1 

in other words , If it's a byte ,8bit, The maximum positive number is 255

If expressed as a negative number The maximum representation range is -2^(N-1) ~ 2^(N-1) - 1

in other words , If calculated in absolute value , The absolute value of a negative number plus the absolute value of a positive number ,

2^(N-1)  + 2^(N-1) - 1 It becomes 2^N -1 

Find negative numbers 2 Hexadecimal complement representation , First find the binary form of positive numbers , Then each bit is reversed , And then add 1 that will do .

In the computer , All data exists in the form of complement , Don't mention the original code , Inverse code or something , Remember to have a headache . Just remember the complement . Because all data exists in complement , Then just remember one .

Then why should it exist in the form of complement ? That genius came up with this storage method ?

Refer to this post , It's very detailed :



A clock chart One minute to understand Computer complement _ Travel great blog -CSDN Blog

The reason why I understand the way clocks express complement , When I was in Graduate School , Our teacher told us , When I finished speaking, it suddenly became clear .

原网站

版权声明
本文为[sgmcy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130612547655.html