CSE 102 Introduction to Computer Engineering Number System
Number Systems Binary numbers (Base 2): 0,1 Octal numbers (Base 8): 0,1,2,3,4,5,6,7 Decimal numbers (Base 10): 0,1,2,3,4,5,6,7,8,9 Hexadecimal numbers (Base 16): 0,1,2,3,4,5,6,7,8, 9,A,B,C,D,E,F
Decimal to Binary Conversion (102)10 = (?)2 = (1100110)2 Divide by 2 Remainder 102 2 51 25 1 12 6 3
Decimal to Binary Conversion (0.125)10 = (?)2 = (0.001)2 Multiply by 2 Integer part 0.125 2 0.25 0.5 1.0 1
Decimal to Binary Conversion Multiply by 2 Integer part 0.4 2 0.8 1.6 1 1.2 (0.4)10 = (?)2 = (0.01100110)2 = (0.0110)2
Binary to Octal and Hexadecimal Conversion (001100110)2 = (146)8 1 4 6 Hexadecimal (1100110)2 = (?)16 (01100110)2 = (66)16 6 6
Binary to Octal and Hexadecimal Conversion (0.011001100)2 = (0.314)8 3 1 4 Hexadecimal (0.01100110)2 = (?)16 (0.01100110)2 = (66)16 6 6
Representation of Integers Signed-magnitude representation 2’s complement representation
Signed-magnitude Representation sign bit 0-positive 1-negative integer Ex: +10210 - 10210 0 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 0
2’s complement Representation To find 1’s complement of a binary number change 1s to 0s and 0s to 1s To find 2’s complement of a number add 1 to its 1’s complement Ex: (102)10 = (0001100110)2 1’s complement: 1110011001 2’s complement: 1110011010
2’s complement Representation Ex: +10210 -10210 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0