0% found this document useful (0 votes)
11 views17 pages

Lecture 2 (1)

The document explains binary arithmetic operations such as addition and subtraction, along with the representation of digital data using binary codes. It details the classification of binary codes into weighted and non-weighted types, including examples like BCD, Excess-3, and Gray codes. Additionally, it covers signed and unsigned binary representations, including sign-magnitude, 1's complement, and 2's complement forms.

Uploaded by

dubeymolly4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
11 views17 pages

Lecture 2 (1)

The document explains binary arithmetic operations such as addition and subtraction, along with the representation of digital data using binary codes. It details the classification of binary codes into weighted and non-weighted types, including examples like BCD, Excess-3, and Gray codes. Additionally, it covers signed and unsigned binary representations, including sign-magnitude, 1's complement, and 2's complement forms.

Uploaded by

dubeymolly4
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 17

BINARY ARITHMETIC

Example: Binary addition


1111 =
carries of 1
1111.01 = (15.25)10
0111.10 = (
7.50)10

10110.11 = (22.75)10

Example: Binary subtraction


1 =
borrows of 1
10010.11 = (18.75)10
01100.10 = (12.50)10
00110.01 = (

6.25)10
BINARY CODE
• The digital data is represented, stored and transmitted as a group of binary bits. This
group is also called binary code.

• It is convenient to represent decimal digits by a sequence of binary digits.

• Several coding techniques have been developed to do so.

• Decimal digits: 0, 1, …, 9 (10) can be represented by 4 bits.

• Since, we need 10 out of 16 values, several codes are possible.

• Binary Codes are classified into 2 types:

• Weighted:

• Non-weighted
BINARY CODE
• Weighted Binary Codes:
• In w eighted code, each digit position has a weight or value.
• The sum of all digits multiplied by a weight gives a total amount being
represented.

• BCD or 8421 is a type of weighted code where each digit position is assigned a
specific weight.

• If x1, x2, x3, x4 are the binary digits, with weights w1 , w2 , w3 , w4 , then
the decimal digit is: N=w 4 x 4 +w 3 x 3 +w 2 x 2 +w 1 x 1

• We say, the sequence (x1, x2, x3, x4) denotes the code word for N.
WEIGHTED BINARY CODE

BCD Self-complementing Codes

Self-complementing code:
Code word of 9’s complement of N obtained by interchanging 1’s and 0’s in the code word of N
NON WEIGHTED BINARY CODE
• In non-weighted code there is no positional weight i.e., Each position within the
binary number is not assigned a prefix value.

• No specific positions are assigned to bit positions in non-weighted code.

• The non-weighted codes are

• Gray code

• Excess-3 code.
BCD TO EXCESS 3 CODE
• Excess-3 codes are unweighted and can be obtained by adding 3 to each decimal
digit then it can be represented by using 4-bit binary number for each digit.

• To find the decimal equivalent of the given binary number. Add 0011 to each four-
bit group in binary coded decimal number (BCD) to get desired excess-3
equivalent.

• The variables B0, B1, B2, and B3 represent the bits of the binary numbers.

• The variable 'B 0 ' represents the LSB, and the variable 'B 3 ' represents the MSB.

• The variables E0, E1, E2, and E3 represent the bits of the Excess-3 code.

• The variable 'E 0 ' represents the LSB, and the variable 'E 3 ' represents the MSB.
BCD TO EXCESS 3 CODE
• The truth table for BCD to Excess-3 code converter can be determined as shown in the
table below.

• For impossible four-bit Excess-3 code, we use the output as Don’t care conditions. The
'don't care conditions' is defined by the variable 'X'.
BCD Number Excess-3 Code Number
Decimal B3 B2 B1 B0 E3 E2 E1 E0
0 0 0 0 0 0 0 1 1
1 0 0 0 1 0 1 0 0
2 0 0 1 0 0 1 0 1
3 0 0 1 1 0 1 1 0
4 0 1 0 0 0 1 1 1
5 0 1 0 1 1 0 0 0
6 0 1 1 0 1 0 0 1
7 0 1 1 1 1 0 1 0
8 1 0 0 0 1 0 1 1
9 1 0 0 1 1 1 0 0
BCD TO GRAY CODE CONVERSION
The Gray code is non-weighted code, as the position of bit does not contain any weight.

The Gray code is a reflective digital code which has the special property that any two subsequent
numbers codes differ by only one bit.

This is also called a unit- distance code.

The generation of 4-bit Gray code can be calculated by using formula.

G 3 = Β3 G 2 = Β 3⊕ Β 2 G 1 = Β 2⊕ Β 1 G 0 = Β 1⊕ Β 0

The most significant bit (MSB) of the Gray code is always equal to the MSB of the given
binary code.

Other bits of the output Gray code can be obtained by XORing binary code bit at that
index and the previous index.
BCD TO GRAY CODE CONVERSION
Four Bit Binary
Four Bit Gray Code
Number
Decimal B3 B2 B1 B0 G3 G2 G1 G0
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 1 0
4 0 1 0 0 0 1 1 0
5 0 1 0 1 0 1 1 1
6 0 1 1 0 0 1 0 1
7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
9 1 0 0 1 1 1 0 1
GRAY TO BCD CONVERSION
In Gray to binary conversion, the input is Gray code and output is its
equivalent binary code.

The generation of four-bit binary equivalent code can be calculated


by using formula.

Β3 = G3 Β2 = G2 ⊕ Β3 Β1 = G1 ⊕ Β2 Β0 = G0 ⊕
Β1
SIGNED AND UNSIGNED BINARY
SIGNED AND UNSIGNED
• Unsigned binary: BINARY
• N bit binary number represents its magnitude only.

• Range 0 to (2n-1)

• Represent decimal number 92 in unsigned binary number.


(92)10 = (1x2 +0x2 +1x2 +1x2 +1x2 +0x2 +0x2 ) = (1011100)
6 5 4 3 2 1 0 10 . 2

It’s 7 bit binary magnitude of the decimal number 92.


• Find the range of 5-bit unsigned binary numbers. Also, find the minimum and
maximum value in this range.
Since the range of unsigned binary numbers is from 0 to (2n-1).
Therefore, the range of 5-bit unsigned binary number is from 0 to (25-1) which is
equal to a minimum value of 0 (i.e., 00000) to a maximum value of 31 (i.e., 11111).
SIGNED AND UNSIGNED
BINARY
• Sign-Magnitude form:
• A binary number has a bit for a sign symbol.

• If this bit is set to 1, the number will be negative else the number will be
positive if it is set to 0.

• Apart from this sign-bit, the n-1 bits represent the magnitude of the number.

• The range of the Sign-Magnitude form is from -(2(n-1)-1) to (2(n-1)-1).

• Two representation of the number zero (0), positive (+0) and negative (-0).

• Range of 6 bit Sign-Magnitude form binary number


• is from -(25-1) to (25-1) which is equal from minimum value -31 (i.e., 1
11111) to maximum value +31 (i.e., 0 11111)
SIGNED AND UNSIGNED
BINARY
• 1’s complement form:
• 1’s complement of a number is obtain ed by inverting each bit of a given number.
• So, we represent positive numbers in binary form and negative numbers in 1’s
complement form.

• There is an extra bit for sign representation.

• Zero (0) can have two representations, that’s why 1’s complement form is also
ambiguous form.

• The range of 1’s complement form is from -(2(n-1)-1) to (2(n-1)-1).

• Range of 6 bit 1’s complement form binary number is from -(25-1) to (25-1) which is
equal from minimum value -31 (i.e., 1 00000) to maximum value +31 (i.e., 0 11111).

• Zero (0) has two representation, -0 (i.e., 1 11111) and +0 (i.e., 0 00000).
SIGNED AND UNSIGNED BINARY
• 2’s complement form:
• 2’s complement of a number is obtained by inverting each bit of a given number plus
1 to least significant bit (LSB).

• So, we represent positive numbers in binary form and negative numbers in 2’s
complement form.

• There is an extra bit for sign representation.

• If the value of the most significant bit (MSB) is 1, then take 2’s complement, else not.

• Zero (0) has only one (unique) representation which is always positive.

• The range of 2’s complement form is from -(2(n-1)) to (2(n-1)-1).

• Range of 6 bit 2’s complement form binary number is from -(25) to (25-1) which is
equal from minimum value -32 (i.e., 1 00000) to maximum value +31 (i.e., 0 11111).
SIGNED AND UNSIGNED
BINARY
• Represent +6 and -6

In Sign-Magnitude Representation: 1's Complement Representation:


+6: +6: 0110 (same as binary)
• Magnitude: 110 (binary for 6) -6:
• Sign: 0 (for positive) • Invert all bits of +6: 1001
• Representation: 0110 • Representation: 1001
-6: 2's Complement Representation:
• Magnitude: 110 (binary for 6) +6: 0110 (same as binary)
• Sign: 1 (for negative) -6:
• Representation: 1110 • Find 1's complement of +6: 1001
• Add 1 to 1's complement: 11001 + 1 = 1010
• Representation: 1010
SIGNED AND UNSIGNED
BINARY
• Represent +120 and -120
• In Sign magnitude form

• In 1’s complement form

• In 2’s complement form

You might also like