Unit 1 BCD Codes
Unit 1 BCD Codes
Unit 1 BCD Codes
Dr Sumit Kumar
Professor
Binary codes
In the coding, when numbers, letters or
words are represented by a specific group of
symbols, it is said that the number, letter or
word is being encoded. The group of symbols
is called as a code. The digital data is
represented, stored and transmitted as group
of binary bits. This group is also called as
binary code. The binary code is represented
by the number as well as alphanumeric letter.
Advantages of Binary Code
Following is the list of advantages that binary
code offers.
Binary codes are suitable for the computer
applications.
Binary codes are suitable for the digital
communications.
Binary codes make the analysis and designing
of digital circuits if we use the binary codes.
Since only 0 & 1 are being used,
implementation becomes easy.
Classification of binary
codes
Weighted Codes
Non-Weighted Codes
Binary Coded Decimal Code
Alphanumeric Codes
Error Detecting Codes
Error Correcting Codes
Weighted Codes
Weighted binary codes are those binary codes
which obey the positional weight principle.
Each position of the number represents a
specific weight. Several systems of the codes
are used to express the decimal digits 0
through 9. In these codes each decimal digit
is represented by a group of four bits.
Non-Weighted Codes
1 1+1 0
1 1+1 1
Gray Code
We can also convert a number represented in the
binary form to Gray code representation. For carrying
out this conversion, we need to remember the
following two rules:
• The Most Significant Bit (MSB) of the binary number
and the gray coded number is always the same.
• The next MSD of the gray coded number can be
obtained by adding the subsequent pair of bits of the
binary number starting from the left.
Gray Code
• Examples 6.12-6.13, Binary Digit Binary
Addition
Gray Coded
Digit
p107. Operation
• 6.12: Convert the 1 1
binary number 0 1+0 1
10100011 to its
1 0+1 1
equivalent Gray coded
number. 0 1+0 1
• Non-decimal to decimal
• Decimal to non-decimal
• Octal to hexadecimal
Computer Arithmetic
Dr Sumit Kumar
Professor
Computer Arithmetic
A computer system stores and processes billions of instructions
in a second that involves a lot of arithmetic computations. The
different arithmetic operations in the computer system are
preformed by the Arithmetic and Logic Unit (ALU).
• Binary addition
• Binary multiplication
• Binary subtraction
• Binary division
Binary Addition
Like decimal system, we can start the addition of two
binary numbers column-wise from the right most bit
and move towards the left most bit of the given
numbers. However, we need to follow certain rules.
1 0 1 0 1 0
+ 0 1 0 0 1 1
1 1 1 1 0 1
Binary Addition
We can also perform the binary addition on more
than two binary numbers.
A B C A+B+C Carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Binary Addition
Example 7.4, p124: Perform the binary addition
operation on the following three numbers: 0010,
0001, 0111.
0 0 1 0
0 0 0 1
+ 0 1 1 1
1 0 1 0
Binary Multiplication
The multiplication of two binary numbers can be
carried out in the same manner as the decimal
multiplication.
Unlike decimal multiplication, only two values are
generated as the outcome of multiplying the
multiplication bit by 0 or 1 in the binary multiplication.
These values are either 0 or 1.
The binary multiplication can also be considered as
repeated binary addition. Therefore, the binary
multiplication is performed in conjunction with the
binary addition operation.
Binary Multiplication
A B AB Example 7.6, p127: Perform the binary multiplication
of the decimal numbers 12 and 10.
0 0 0
0 1 0 The equivalent binary representation of the decimal number 12 is 1100.
The equivalent binary representation of the decimal number 10 is 1010.
1 0 0
1 1 0 0
1 1 1 1 0 1 0
Binary multiplication 0 0 0 0
does not involve the 1 1 0 0
concept of carry. 0 0 0 0
1 1 0 0
1 1 1 1 0 0 0
Binary Subtraction
The binary subtraction is performed in the same way
as the decimal subtraction. Like binary addition and
binary multiplication, binary subtraction is also
associated with a set of rules that need to be
followed while carrying out the operation.
A B A-B Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Binary Subtraction
Examples 7.10 and 7.11, p129.
7.11: Perform the binary subtraction of the following
numbers: 10101 and 01110
1 1 1
1 0 1 0 1
- 0 1 1 1 0
0 0 1 1 1
Binary Division
Binary division is also performed in the same way as we
perform decimal division. Like decimal division, we also need
to follow the binary subtraction rules while performing the
binary division. The dividend involved in binary division should
be greater than the divisor. The following are the two
important points, which need to be remembered while
performing the binary division.
1 0 0 0 ) 1 0 0 1 0 ( 1 0 Quotient
1 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 1 0 Remainder
Signed/Unsigned Numbers
The unsigned binary number is the number with a
magnitude of either zero or greater than zero, and
are usually represented using the unsigned-
magnitude representation, which only represents the
magnitude of the numbers.
0 0 1 1 0 0 1 0 50
Sign bit
1 0 1 1 0 0 1 0 -50
Signed/Unsigned Numbers
Advantages of the signed-magnitude representation:
One’s complement
Two’s complement
One’s Complement
One’s complement method can be used to represent
negative binary numbers.
Sign bit
1 1 1 1 0 0 0 0 -15
One’s Complement
Integers One’s complement representation
-7 1000
-6 1001 The one’s complement
-5 1010
method of representing
-4 1011
signed numbers also
-3 1100
-2 1101
has two different
-1 1110 representations for the
-0 1111 number, zero.
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
One’s Complement
Example 7.18 (P134): Represent -25 in the one’s
complement system in byte size.
Sign bit
1 1 1 1 0 0 0 1 -15
Two’s Complement
Integers Two’s complement representation
-7 1001
-6 1010
-5 1011
-4 1100
-3 1101
-2 1110
-1 1111
-0 0000
+0 0000
+1 0001
+2 0010
+3 0011
+4 0100
+5 0101
+6 0110
+7 0111
Two’s Complement
Example 7.21 (P136): Represent -33 in the two’s
complement system in byte size.