Details of the original code inverse code and complement code storage and size
- 2020-05-24 05:53:36
- OfStack
Details of the original code, inverse code and complement code storage and size
The original code:
If the machine word length is N bit, then the source code of 1 number is N bit 2 base number, the highest bit
It's the sign bit, 1 for a negative number, 0 for a positive number.
Radix-minus-one complement:
The negative of a positive number is the same as the original, the negative of a negative number is the same as the sign bit.
Complement:
The complement of a positive number is the same as its source code; The complement of a negative number is to add 1 to the last bit of its inverse.
(all Numbers in a computer are stored in the form of complement)
The form of the complement is used for adding and subtracting positive and negative 2 bases
char is 1 byte, 8 bit bits, how is it stored in memory
106 Into the system 2 The actual value of the base (complement) code
char a = 127; //7f 0111 1111 127
char b = 128; //80 1000 0000 0111 1111 1000 0000 -128
char c = -128; //80 1000 0000 0111 1111 1000 0000 -128
char d = -1; //ff 1111 1111 1111 1110 1000 0001 -1
-128 and you might have a question, 1000 0000 is a negative number, so if you go back to the complement and the inverse of the original code, you subtract 1 to 0111, 1111, and if you go back to 1000 0000, you get 128, because it's a negative number, you get -128.
So signed char has a maximum of 127 and a minimum of -128.
unsigned is unsigned, meaning there is no sign bit.
unsigned char e = 256; //00 0000 0000 0
unsigned char f = -1; //ff 1111 1111 255
unsigned char g = 255; //ff 1111 1111 255
Since there is no sign bit, the original reverse complement code is all 1, why is the value of -1 255, the original code of -1 0000 0001 (no sign bit), the inverse code 1111 1110, the complement code
Thank you for reading, I hope to help you, thank you for your support of this site!