Lecture 02 OCTAL AND HEXADECIMAL NUMBER SYSTEMS PROF
Lecture 02: OCTAL AND HEXADECIMAL NUMBER SYSTEMS PROF. INDRANIL SENGUPTA DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Octal Number System • A compact way to represent binary numbers. – Group of three binary digits are represented by a octal digit. – Octal digits are 0 to 7. Octal Binary 0 000 1 001 2 010 3 011 4 100 5 101 6 110 7 111 Switching Circuits & Logic Design 2
Binary to Octal Conversion • For the integer part: – Scan the binary number from right to left. – Translate each group of three bits into the corresponding octal digit. • Add leading zeros if necessary. • For the fractional part: – Scan the binary number from left to right. – Translate each group of three bits into the corresponding octal digit. • Add trailing zeros if necessary. Switching Circuits & Logic Design 3
Examples (Binary to Octal) 1. (101 000 011)2 = (5503)8 2. (1 010 100 001)2 = (1241)8 Two leading 0 s are added 3. (. 100 001 1)2 = (. 414)8 Two trailing 0 s are added 4. (11. 010 111 1)2 = (3. 274)8 A leading 0 and two trailing 0 s are added Switching Circuits & Logic Design 4
Octal to Binary Conversion • Translate every octal digit into its 3 -bit binary equivalent. • Examples: (1645)8 = (001 110 101)2 (22. 172)8 = (010 010. 001 111 010)2 (1. 54)8 = (001. 101 100)2 Switching Circuits & Logic Design 5
Hexadecimal Number System • A compact way to represent binary numbers. – Group of four binary digits are represented by a hexadecimal digit. – Hexadecimal digits are 0 to 9, A to F. Hex Binary 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 C 1100 5 0101 D 1101 6 0110 E 1110 7 0111 F 1111 Switching Circuits & Logic Design 6
Binary to Hexadecimal Conversion • For the integer part: – Scan the binary number from right to left. – Translate each group of four bits into the corresponding hexadecimal digit. • Add leading zeros if necessary. • For the fractional part: – Scan the binary number from left to right. – Translate each group of four bits into the corresponding hexadecimal digit. • Add trailing zeros if necessary. Switching Circuits & Logic Design 7
Examples (Binary to Hexadecimal) 1. (1011 0100 0011)2 = (B 43)16 2. (10 1010 0001)2 = (2 A 1)16 Two leading 0 s are added 3. (. 1000 010)2 = (. 84)16 A trailing 0 is added 4. (101. 0101 111)2 = (5. 5 E)16 A leading 0 and trailing 0 are added Switching Circuits & Logic Design 8
Hexadecimal to Binary Conversion • Translate every hexadecimal digit into its 4 -bit binary equivalent. • Examples: (3 A 5)16 = (0011 1010 0101)2 (12. 3 D)16 = (0001 0010. 0011 1101)2 (1. 8)16 = (0001. 1000)2 Switching Circuits & Logic Design 9
Decimal to Radix-r and Vice Versa • We follow a principle similar to decimal-binary and binary-decimal conversion as discussed earlier. • Radix-r to decimal: – Multiply each digit by corresponding weight and add them up. • Decimal to radix-r: – For the integer part, repeatedly divide the number by r and accumulate the remainder. Remainders are arranged in reverse order. – For the fractional part, repeatedly multiply by r, and accumulate & discard the integer part. The digits are arranged in the order they are generated. Switching Circuits & Logic Design 10
END OF LECTURE 02 Switching Circuits & Logic Design 11
- Slides: 11