CSE 102 Introduction to Computer Engineering Number System
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 102 2 51 2 25 12 6 3 1 0 2 2 2 Remainder 0 1 1 0 0 1 1
Decimal to Binary Conversion (0. 125)10 = (? )2 = (0. 001)2 Multiply by 2 Integer part 0. 125 2 0. 5 2 1. 0 2 0 0 1
Decimal to Binary Conversion (0. 4)10 = (? )2 = (0. 0110)2 Multiply by 2 Integer part 0. 4 2 0. 8 1. 6 1. 2 0. 4 2 2 0 1 1 0 0. 8 2 1. 6 2 1. 2 2 0 1 1 0. 4 2 0
Binary to Octal and Hexadecimal Conversion • Octal (1100110)2 = (? )8 (00110)2 = (146)8 1 4 6 • Hexadecimal (1100110)2 = (? )16 (0110)2 = (66)16 6 6
Binary to Octal and Hexadecimal Conversion • Octal (0. 0110)2 = (? )8 (0. 01100)2 = (0. 314)8 3 1 4 • Hexadecimal (0. 0110)2 = (? )16 (0. 0110)2 = (66)16 6 6
Representation of Integers • Signed-magnitude representation • 2’s complement representation
Signed-magnitude Representation sign bit 0 -positive 1 -negative Ex: +10210 - 10210 integer 0000110 1000110
2’s complement Representation • To find 1’s complement of a binary number change 1 s to 0 s and 0 s to 1 s • To find 2’s complement of a number add 1 to its 1’s complement Ex: (102)10 = (000110)2 1’s complement: 111001 2’s complement: 1110011010
2’s complement Representation Ex: +10210 -10210 000110 1110011010
- Slides: 11