Representation of negative numbers
Negative numbers are represented by positive negation +1. The principle is that the positive and negative additions are 0; In the computer world, 0 is considered a positive number, not a non-positive or negative in the mathematical world.
Binary representation of negative numbers:
5:00000101
-5:11111011 (positive members, +1)
5+ (-5) = 100000000 1 overflow result is 0
The process and principle of converting a number of byte type to 16 binary number
The byte type takes up 8 bits, converts it to 16 decimal, converts the lower four bits to the 0x0f phase, and converts the high four bits into 0000
The high four-bit shifts the right 4, and then the 0x0f phase, as with 0x0f, so whether a signed right shift is no longer meaningful, because after the & operation, whether or not there is a symbol, the high point becomes 0. The procedure is as follows:
public static String convert (Byte b) {
int low = B & 0x0F;
int high = (b >> 4) & 0x0F;
Char[] arr = {' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' D ', ' E ', ' F '};
Return "" + Arr[high] + Arr[low];
}