1. What is the representation of negative numbers and why is it so designed?
A negative number is represented by a positive inverse plus one. The principle is that the sum of positive and negative numbers is 0. When the design plus and minus values are added, the first 1 will overflow due to exceeding the presentation range. Get the correct values for the complement notation.
For example, the number of binary representations of byte type, 0001 + 0111 1111 = (byte type is 8 bits, the 9th bit is 1 over range) 1 0000 0000, so take the front 8 bits, 0000 0000, the value is 0.
--------------------------------------------------
How is 2.-128 stored in memory? The calculation process?
128 in a 8-bit byte storage structure =1000 0000, in complement notation, 1000 0000 of the complement is also 1000 0000, because its sign bit is 1, which represents a negative number it represents-128.
If you calculate-128 by 127-1, the process is as follows
+127=0111 1111,-127=1000 0001,-128=-127-1=1000 0000
-------------------------------------------------
3. If the byte is represented as 11111111, what is its true data?
From the sign bit this is a negative number, first get its positive number. 1111 1111 of the inverse plus 1 is 0000 0001, the real data is +1
--------------------------------------------------
4. Do positive and negative numbers support the complement approach?
Positive and negative numbers support the complement approach
---------------------------------------------------
5. Is the positive number minus one negation?
Yes, 127=0111 1111=~ (+ 0001-1) =~1000 0000= 0111 1111
126=0111 1110=~ (+ 0010-1) =~1000 0001=0111 1110
125=0111 1101=~ (+ 0011-1) =~1000 0010=0111 1101
Java Foundation The second day _ binary conversion principle and complement storage method