The design of the computer is really exquisite.Recently I have seen some original codes and inverse codes , Complementary code, I am very surprised that the correct result can be obtained by using the complemented code calculation, but I always feel that there is an inherent logic in it.This article is my thoughts after seeing an example of a clock on the Internet, and some sort of understanding.
First list the original code, inverse code, complement code related things:
the original code: the original code is The binary code of a number, for example, the original of 3 is 00...011Inverse code: The inverse code refers to the original code.The rule is that the inverse code of a positive number is itself, and the sign bit of the inverse code of a negative number remains unchanged.Other inversions,
One's complement: One's complement is to add 1 to the one's complement
Suppose we want to perform a very simple computer operation: such as subtraction 3-2, when it is done in a computer, it is 3+(-2).We know that the calculation has a maximum value.When adding in binary, if the sum of the highest bit reaches 2, we have to move forward one bit, But at this time, the highest bit cannot be represented.We just throw it away.For example, an unsigned number represented by 8 bits: 255, its binary is 11111111.If you add 1 to this value, then the result is actually "100000000", but at this time has exceeded the sum of its bit data, the first 1 cannot be represented, so its value is 0 in the calculation because it overflows.It is precisely because of this overflow mechanism that we can think like this.
First overflow has a critical value, such as the above 8-bit binary, its overflow critical value is 256 (unsigned can represent so much, if there is a sign, it can only represent 128), that is, the maximum value is 256 , Which is also equivalent to 256 is equal to 0, so we can think about it this way.
Arbitrary data=arbitrary number+0=arbitrary number+overflow threshold (256 in the above example),
So when you subtract in the computer, you can In this way:
3-2 =3+overflow threshold-2= 3+ (overflow threshold-2) is actually equal to = 3+ (-2 of Complement).
Because the complement of a positive number is itself, the above formula is ultimately equal to = 3’s complement + (-2’s Complement).
3-2 = 3+overflow threshold -2 = 3+ (overflow threshold -2) is actually equal to = 3+ (-2's complement).Because the complement of a positive number is itself, the above formula is ultimately equal to = 3’s complement + (-2’s Complement).
3-2 = 3+overflow threshold -2 = 3+ (overflow threshold -2) is actually equal to = 3+ (-2's complement).Because the complement of a positive number is itself, the above formula is ultimately equal to = 3’s complement + (-2’s Complement).
purchase lipitor generic & lt;a href="https://lipiws.top/"& gt;lipitor 40mg drug& lt;/a& gt; buy atorvastatin for sale
Yrwusf
2024-03-08