0% found this document useful (0 votes)
29 views8 pages

DLD - Lec2 (2) - 1

The document discusses binary-coded decimal (BCD) representation and how it allows decimal numbers to be represented using binary. It then covers how to convert decimal numbers to BCD and discusses some limitations of the BCD system. The document also discusses various binary coding schemes and arithmetic operations like addition, subtraction, multiplication, and division in binary systems.

Uploaded by

4dham.xi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views8 pages

DLD - Lec2 (2) - 1

The document discusses binary-coded decimal (BCD) representation and how it allows decimal numbers to be represented using binary. It then covers how to convert decimal numbers to BCD and discusses some limitations of the BCD system. The document also discusses various binary coding schemes and arithmetic operations like addition, subtraction, multiplication, and division in binary systems.

Uploaded by

4dham.xi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Digital Logical Design

Lecture 2

Binary-Coded Decimal (BCD) Presentation

The binary-code decimal representation is a compromise between the decimal and


binary number systems. In BCD, four bits (a nibble) is used to represent each of the
decimal digits from 0 to 9. To represent a decimal number beyond 9, two or more
decimal digits are needed. Hence, BCD representation requires two or more nibbles.
The next table shows binary and BCD equivalents of decimals from 0 to 15.

Table: Decimal, Binary, and BCD relationships


Decimal Binary BCD
0 0000 0000 0000
1 0001 0000 0001
2 0010 0000 0010
3 0011 0000 0011
4 0100 0000 0100
5 0101 0000 0101
6 0110 0000 0110
7 0111 0000 0111
8 1000 0000 1000
9 1001 0000 1001
10 1010 0000 0001
11 1011 00010001
12 1100 00010010
13 1101 00010011
14 1110 00010100
15 1111 00010101

Note that a nibble can actually represent 16 numbers


(decimals 0 to 15); however, the BCD system uses only ten of them. It should be
understood that BCD is just a code in binary as opposed to straight binary number that
represents the actual value. Generally, each decimal digit is independently represented
by its corresponding binary nibble in order to find the BCD representation of a
decimal number.

Convert (3729)10 to BCD


Note that this conversion is much simpler than the conversion of (3729) 10 to binary.
To convert (3729)10 to binary, repeated division is to be used resulting
(111010010001)2. From this example, the inefficiency of the BCD representation is
clearly obvious. The binary representation of (3729)10 requires 12 bits while the BCD
equivalent uses 16 bits. Henceforth, the larger the decimal number is, the most
wasteful its BCD representation becomes. However, using BCD system is simpler and
more convenient that makes it up for its inefficiency.

Binary codes
Binary codes for decimal digits require a minimum of four bits. Numerous different
codes can be obtained by arranging or more bits in ten distinct possible combinations:

Decimal (BCD) Biquinary


Digit 8421 Excess-3 84-2-1 2421 5043210
0 0000 0011 0000 0000 0100001
1 0001 0100 0111 0001 0100010
2 0010 0101 0110 0010 0100100
3 0011 0110 0101 0011 0101000
4 0100 0111 0100 0100 0110000
5 0101 1000 1011 1011 1000001
6 0110 1001 1010 1100 1000010
7 0111 1010 1001 1101 1000100
8 1000 1011 1000 1110 1001000
9 1001 1100 1111 1111 1010000
Arithmetic Operation
By now, we should have agreed on the data in digital systems are binary numbers and
other binary-coded information that are operated on to achieve computational results.

Binary addition
It works in the same way as the decimal addition, except that only 0's and 1's can be
used, instead of the whole spectrum of 0-9. This actually makes binary addition much
simpler than decimal addition, as we only need to remember the following:
0+0=0
0+1=1
1+0=1
1 + 1 = 10

As an example of binary addition we have,

101 +101

a) To add these two numbers, we first consider the "ones" column and calculate 1 + 1,
which (in binary) results in 10. We "carry" the 1 to the "tens" column, and the leave
the 0 in the "ones" column.
b) Moving on to the "tens" column, we calculate 1 + (0 + 0), which gives 1. Nothing
"carries" to the "hundreds" column, and we leave the 1 in the "tens" column.
c) Moving on to the "hundreds" column, we calculate 1 + 1, which gives 10. We
"carry" the 1 to the "thousands" column, leaving the 0 in the "hundreds" column.

101
+101
------
1010
Another example of binary addition:
1011
+1011
--------
10110

Binary Multiplication
11001012 × 1111012 (10110 × 6110)

1100101 10110
× 111101 × 6110
-------
1100101
+1100101
+1100101
+1100101
+1100101
-------------
?????????????
-------------
Easier to use intermediary results:

1100101 10110
× 111101 × 6110
-------
1100101
+1100101
----------
111111001
+1100101
------------
10100100001
+1100101
-------------
101101110001
+1100101
-------------
1100000010001 = 409610 + 204810 + 1610 + 1 = 616110

Binary Division
1001012 ÷ 1012 (3710 ÷ 510)
111 result = 710
-------
101)100101
−101
---
1000
−101
---
111
−101
---
10 remainder = 210
---
Binary subtraction
It is simplified as well, as long as we remember how subtraction and the base 2
number system. Let's first look at an easy example.
111
- 10
101
Note that the difference is the same if this was decimal subtraction. Also similar to
decimal subtraction is the concept of "borrowing." This seems easiest when
performing subtraction with paper and pencils. When subtraction is performed by
digital components, this method is found to be less efficient than the method that uses
complements and addition as stated below
Complements
Complements are used in digital systems to simplify the subtraction operation and for
logical manipulations. There are two types of complements for each base-r system:
(1) the (r-1)’s complement and (2) the r’s complement. When the value of the base is
substituted, the two types receive the names 1’s and 2’s complement for binary
numbers, or 9’s and 10’s complement for decimal numbers.

The (r-1)’s complement


Given a positive number N in base r with an integer part of n digits and a fraction part
of m digits, the (r-1)’s complement of N is defined as
Consider the examples:
 Obtain 9’s complement of (4857.43)10
n=4 and m=2
the 9’s complement of (4857.43)10 is

 Find the 1’s complement of (101100)2


n=6 and m=0
the 1’s complement of (101100)2

 Find the 1’s complement of (0.0110)2


n=0 and m=4
the 1’s complement of ( )2

From the examples, it is seen that the 9’s compliment of the decimal number is
formed simply by subtracting every digit from 9. The 1’s compliment of a binary
number is even simpler to from: the 1’s are changed to 0’s.

The r’s compliment


Given a positive number N in base r with an integer part of n digits, the r’s
complement of N is defined as for and 0 for . The following
examples will clarify this equation:

 Find the 10’s complement of (52520)10


n =5
the 10’s complement of (52520)10 is

 Find the 2’s complement of (101100)2


n =6
the 2’s complement of (101100)2 is

 Find the 2’s complement of (0.0110)2


n =0
the 2’s complement of (0.0110)2 is

From the definition and the examples, it is clear that the 10’s complement of the
decimal number can be obtained by leaving all least significant zeros unchanged,
subtracting the first nonzero digit from 10, and then subtracting all other higher
significant digits from 9. The 2’s complement can be formed by leaving all least
significant zeros and the first nonzero digit unchanged, and then replacing 1’s by
0’s and 0’s by 1’s in all other higher significant digits.
Another simpler way is derived from both the definition of both the r’s and (r-1)’s
complements. The r’s complement can be achieved from the (r-1)’s complement after
the addition of r-m to the least significant digit. For example the 2’s complement of
10110100 is obtained from the 1’s complement 01001011 by adding 1 to give
01001100.
It is worth mentioning that the complement of the complement restores the number to
its original value. The r’s complement of N is rn-N and the complement of rn-N is rn-
(rn-N) =N; and similarly for the 1’s complement

Subtraction by 2’s complement


The subtraction of two positive numbers (M-N), both of base r, may be done as
follows:
1. Add the minuend M to the 2’s complement of the subtrahend N
2. Inspect the result obtained in step 1 for the end carry:
a. If an carry occurred discard it
b. If there is no end carry, take the r’s complement of the number
obtained in step 1 and place a negative sign in front.
Example:
M= 1010100
N= 1000100
2’s complement of N = 0111100

1010100
+0111100
----------------
10010000 -------------------------- the answer is 10000 after discarding the end carry

M= 1000100
N= 1010100
2’s complement of N = 0101100

1000100
+0101100
---------------
1110000------------------------- the answer is -00110000
no carry this means we should take the 2’s complement of this results with a negative
sign

Subtraction by 1’s complement


The procedure for the subtraction with 1’s complement is exactly the same as the one
used with the 2’s complement except for one variation, called “end-around carry”, as
shown below. The subtraction of M-N, both positive numbers in base r may be
calculated in the following manner:
1. Add the minuend M to the 1’s complement of the subtrahend N
2. Inspect the results obtained in step 1 for an end carry
a. If an end carry occurs add1 to the least significant bit (end-around
carry)
b. If an end carry doesn’t occur, take the 1’s complement of the number
obtained in step 1 and place a negative sign in front
Examples
M = 1010100
N = 1000100
1’s complement of N = 0111011

1010100
+ 0111011
--------------
1 0001111-------------------------there’s a carry, the result is 0010000 after adding 1
to the least significant bit

M = 1000100
N = 1010100
The 1’s complement of N is 0101011

1000100
+ 0101011
-----------------
1 101111---------------------- there is no carry, the result is –(1’s complement of
the previous result) = -0010000
Comparison between 1’s and 2’s complements

1’s Complement 2’s complement


Easier to implement by digital Can be obtained either by
components since the only thing that 1. adding 1 to the least significant bit
must be done is to change 1’s to zero’s to the 1’s complement
and zero’s to 1’s 2. leaving all 0’s in the least
significant bit and the first 1
unchanged then change 1’s and
0’s
Requires two additions during subtraction During subtraction, just one arithmetic
when an end carry occurs addition operation is required.
Posses two arithmetic 0’s illustrated as 1100-0011
follows: 1100-1100
1100 1100
+0011 +0100
------- ---------
1111- no carry, take 1’s complement 1 0000 -- discard the carry so the result
and a minus sign -0000 is 0000

Used in logical manipulations Used only with the conjunction of


Hence, if the word complement is used arithmetic operations
without mentioning the type in non-
arithmetic context, it is assumed to be 1’s
complement.

You might also like