Tag: Represents a byte size positive number inverse code style review binary
The value range of Java Byte we all know (-128 ~ 127), then-128 and 127 How are the two numbers calculated?
#大学知识回顾:
Concept: The complement of a negative number is the absolute value of the original code bitwise negation, and then the entire number plus 1
There are 3 representations of the fixed-point number in the computer: original code, inverse code, and complement
The [original code] is the binary fixed-point notation described earlier, that is, the highest bit is the sign bit, "0" is positive, "1" is negative, and the remaining bits represent the size of the value.
[Anti-code] notation: The inverse of a positive number is the same as its original code; the inverse of a negative number is a bitwise negation of its original code, except for the sign bit.
The [complement] notation stipulates that the complement of positive numbers is the same as the original code, and the complement of negative numbers is added to the minus 1 of the inverse code.
Java uses the complement to represent the binary number, in the complement representation, the highest bit is the sign bit, the positive sign bit is 0, the negative number is 1.
Now for the Java Byte Value range analysis:
1. Determine that byte is 1 bytes, or 8 bits
2, for the computer, the binary maximum positive number is 01111111 converted to decimal: 127
3, the smallest negative number: 10000000, that is-128
Binary negative value: Take the inverse plus one, so the value of 10000000 is:
1. Reverse-01111111 127
2. Add a - 128
3. Plus symbol: -128
Java byte value range