/*
Different binary data performance:
Binary: Consists of 0, 1. Start with 0b.
Octal: by 0,1,... 7 composition. Start with 0.
Decimal: By 0,1,... 9 composition. The default integer is decimal.
Hex: by 0,1,... 9,a,b,c,d,e,f (both uppercase and lowercase) are composed. Start with 0x.
*/
Class Jinzhidemo {
public static void Main (string[] args) {
SYSTEM.OUT.PRINTLN (100); Decimal
System.out.println (0b100); Binary
System.out.println (0100); Octal
System.out.println (0x100); Hexadecimal
}
}
1: Get the decimal value of the following data:
0b10101
=1*2^4 + 1*2^2 + 1*2^0
=16 + 4 + 1
=21
0123
=1*8^2 + 2*8^1 + 3*8^0
=64 + 16 + 3
=83
0x3c
=3*16^1 + c*16^0
=48 + 12
=60
2: Binary, decimal, hexadecimal for the data below
52 respectively get binary, decimal, hexadecimal
Get binary:
52/2 = 26 0
26/2 = 13 0
13/2 = 6 1
6/2 = 3 0
3/2 = 1 1
1/2 = 0 1
0b110100
Get octal:
52/8 = 6 4
6/8 = 0 6
064
Get 16 binary:
52/16 = 3 4
3/16 = 03
0x34
3: Practice of symbolic data representation
A: It is known that a number of X's original code is 10110100B, try to find X's complement and anti-code.
Sign bit Value bit
Original code: 10110100
Anti-code: 11001011
Complement: 11001100
B: A number of X's complement 11101110B is known, try to find its original code.
Sign bit Value bit
Complement: 11101110
Anti-code: 11101101
Original code: 10010010
4:
Java-based binaries