Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Lecture 02: OCTAL AND HEXADECIMAL NUMBER SYSTEMS

PROF. INDRANIL SENGUPTA


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Octal Number System
Octal Binary
• A compact way to represent
0 000
binary numbers.
1 001
– Group of three binary digits are 2 010
represented by a octal digit.
3 011
– Octal digits are 0 to 7. 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 101 000 011)2 = (5503)8
2. (1 010 100 001)2 = (1241)8 Two leading 0s are added

3. (.100 001 1)2 = (.414)8 Two trailing 0s are added

4. (11 . 010 111 1)2 = (3.274)8 A leading 0 and two


trailing 0s 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 100 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 Hex Binary Hex Binary
numbers. 0 0000 8 1000
– Group of four binary digits are 1 0001 9 1001
represented by a hexadecimal digit. 2 0010 A 1010
– Hexadecimal digits are 0 to 9, A to F. 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 = (B43)16
2. (10 1010 0001)2 = (2A1)16 Two leading 0s are added

3. (.1000 010)2 = (.84)16 A trailing 0 is added

4. (101 . 0101 111)2 = (5.5E)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:
(3A5)16 = (0011 1010 0101)2
(12.3D)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

You might also like