Module 3
Module 3
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F
Counting in Hexadecimal
Example:
11010110101110010110
D 6 B 9 6
Binary to Hexadecimal Conversion
Example:
As shown in Equation , extra 0’s are added at each end of
the bit string as needed to fill out the groups of four bits.
Example:
Hexadecimal to Binary Conversion
Hexadecimal to Binary Conversion
Conversion from hexadecimal to binary is done by reversing the preceding
procedure.
Each hexadecimal digit is converted to its four-digit binary equivalent.
FD13
1111 1101 0001 0011
Hexadecimal to Binary Conversion
11
Decimal to Hexadecimal Conversion
Decimal to Hexadecimal Conversion
Repeated Division by 16
Step 1: First, divide the decimal number by 16, considering the number as an integer.
Step 2: Keep aside the remainder.
Step 3: Again divide the quotient by 16 and repeat till you get the quotient value equal
to zero.
Step 4: Now take the values of the remainder’s left in the reverse order to get the
hexadecimal numbers
Decimal to Hexadecimal Conversion
Decimal to Hexadecimal Conversion
2096 131 0
131 8 3
8 0 8
Decimal to Hexadecimal Conversion
Decimal to Hexadecimal Conversion
Hexadecimal to Decimal Conversion
Hexadecimal to Decimal Conversion
Sum-of-Weights
Example: Convert CA02 to Decimal using Sum of
Weights technique
Solution:
CA02
= (C x 163) + (A x 162) + (0 x 161) + (2 x 160)
= (12 x 163) + (10 x 162) + (0 x 161) + (2 x 160)
= (12 x 4096) + (10 x 256) + (0 x 16) + (2 x 1)
= 49152 + 2560 + 0 + 2
= 51714
5. Octal Number System
5. Octal Number System
It is a base‐8 system
22
Table shows the decimal and binary equivalents of the Octal
digits 0 to 7
011010110101110010110
011 010 110 101 110 010 110
3 2 6 5 6 2 6
Binary to Octal Conversion
• Example:
1011011101001
1 011 011 101 001
001 011 011 101 001
1 3 3 5 1
Octal to Binary Conversion
Octal to Binary Conversion
• Example:
• Consider the 4 digit Octal number which is to be converted into Binary
• Each Octal digit is replaced by its equivalent 3-bit binary number.
• Thus Octal 1 is replaced by 001
• Octal 7 is replaced by 111
• Octal 2 is replaced by 010
• And Octal 6 is replaced by 110
1726
001 111 010 110
Decimal-Octal Conversion
Decimal-Octal Conversion
• Repeated Division by 8
• Example:
• Consider the Repeated division by 8 method to convert Decimal 2079 into Octal
• The decimal number 2079 is divided by 8 which results in a quotient value of 259 and the remainder
7 Number Quotient Remainder
• The remainder 7 is noted and the quotient 259 is divided by 8.
• 259 divided by 8 results in a quotient value of 32 and a remainder value of 3. 2079 259 7
The remainder 3 is noted and the quotient 32 is divided by 8.
(a0)
•
Example:
• Consider the Sum-of-Weights 4037
method to convert Octal 4037 to
Decimal =(4 x 83) + (0 x 82) + (3 x 81) + (7 x 80)
• An expression in terms of the base =(4 x 512) + (0 x 64) + (3 x 8) + (7 x 1)
number 8 and weights is written =2048 + 0 + 24 + 7
• The expression is solved to give four =2079
sum terms 2048, 0, 24 and 7
• The four terms are added to result in
the number 2079 the decimal
equivalent of Octal 4037
Alternate Representations
35
BCD (Binary Coded Decimal) Code
36
BCD (Binary Coded Decimal) Code
• Most digital systems display a count value or the
time in decimal on 7-segment LED display panels.
41
BCD Addition
23 0010 0011
45 0100 0101
68 0110 1000
23 0010 0011
49 0100 1001
72 0110 1100
1100 is illegal BCD number
Note:
This means that although 16 numbers (24) can be represented using four binary
digits, in the BCD numbering system the six binary code combinations of: 1010
(decimal 10), 1011 (decimal 11), 1100 (decimal 12), 1101 (decimal 13), 1110
(decimal 14), and 1111 (decimal 15) are classed as forbidden numbers and can
not be used
BCD Addition
Add a 0110 (6) to an invalid BCD
number
Carry added to the most significant BCD
digit • When addition of BCD
digits results in an invalid
BCD number or a
23 0010 0011 carry.The number 0110 (6
decimal) is added to the
49 0100 1001 result.
• Reconsidering the
72 0110 1100 addition of BCD 23 and
49. The addition of digits
0110 3 and 9 results in 1100 an
0111 0010 invalid BCD number
• A 0110 decimal 6 is
added which results in
0010 and a carry which is
added to 0110 to result in
Why So ?????
44
BCD Addition
Example:
Gray Code
46
Gray Code
The reflected binary code or Gray code is an ordering of the binary
numeral system such that two successive values differ in only one
bit (binary digit).
A Gray code has the property that the codes for successive decimal
digits differ in exactly one bit. For example, the codes for 6 and 7
differ only in the fourth bit, and the codes for 9 and 0 differ only in
the first bit.
47
Gray Code
48
Gray Code
The output data of many physical systems are quantities that are
continuous. These data must be converted into digital form before they are
applied to a digital system.
The advantage of the Gray code over the straight binary number
sequence is that only one bit in the code group changes in going from
one number to the next.
49
Constructing an n-bit Gray code
• n-bit Gray code can be generated recursively
using reflect and prefix method which is
explained as following below.
If binary numbers are used, a change, for example, from 0111 to 1000 may
produce an intermediate erroneous number 1001 if the value of the
rightmost bit takes longer to change than do the values of the other three
bits. This could have serious consequences for the machine using the
information.
The Gray code eliminates this problem, since only one bit changes its
value during any transition between two numbers
Alphanumeric Code
Alphanumeric Code
Alphanumeric codes (also known as character codes) are
defined as binary codes used to represent alphanumeric data.
In 1967 this code was first published and since then it is being modified
and updated.
• For example, the ASCII code for lower case z is 122 and is shown
below
Alphanumeric Code
ASCII code (American Standard Code for Information Interchange)
Numbers 0 to 9
ASCII 0110000 (30hex) to 0111001 (39hex)
Alphabets a to z
ASCII 1100001 (61hex) to 1111010 (7Ahex)
Alphabets A to Z
ASCII 1000001 (41hex) to 1011010 (5Ahex)
• In 1981, IBM developed an extension of 8-bit ASCII code, called "code page
437", in this version were replaced some obsolete control characters for
graphic characters.
• Added 128 new symbols, signs, graphics and Latin letters, all punctuation
signs and characters needed to write texts in other languages, such as
Spanish ((Non Standard Characters)
• This is because extended ASCII uses eight bits to represent a character as
opposed to seven in standard ASCII (where the 8th bit is used for error
checking).
• The maximum number of characters that can be represented in extended
ASCII is 256
58
Alphanumeric Code
EBCDIC code (Extended Binary Coded Decimal Inter change code)
IBM invented this code to extend the Binary Coded
Decimal which existed at that time.
59
Alphanumeric Code
Unicode
Unicode is the newest concept in digital coding.
Leading technological giants have adopted this code for its uniqueness
It is aimed to include all the characters needed for any writing system or language.
Unicode uses 8-bit, 16-bit or 32-bit encoding. so it can represent 28 , 216, , 232 ,
characters
respectively.
Unicode represents a wide range of characters including different languages, mathematical symbols and
emojis
Unicode occupies more space and is more demanding on memory than ASCII
60
Error Detection
Parity Bit
Even Parity
Odd Parity
Odd Parity Error Detection
Original data 10011010
With Odd Parity 110011010