0% found this document useful (0 votes)
82 views26 pages

Binary Arithmetic Operations: Prof. R.Ezhilarasie Assistant Professor School of Computing SASTRA Deemed To Be University

1. The document discusses binary arithmetic operations and binary codes. 2. It explains how to perform basic arithmetic operations like addition, subtraction, multiplication, and division on binary numbers. Rules for operating on signed binary numbers are also provided. 3. Different methods for representing signed binary numbers like sign-magnitude, 1's complement, and 2's complement are described. Arithmetic operations can then be performed on signed binary numbers based on their representation.

Uploaded by

Ezhil Ramanathan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views26 pages

Binary Arithmetic Operations: Prof. R.Ezhilarasie Assistant Professor School of Computing SASTRA Deemed To Be University

1. The document discusses binary arithmetic operations and binary codes. 2. It explains how to perform basic arithmetic operations like addition, subtraction, multiplication, and division on binary numbers. Rules for operating on signed binary numbers are also provided. 3. Different methods for representing signed binary numbers like sign-magnitude, 1's complement, and 2's complement are described. Arithmetic operations can then be performed on signed binary numbers based on their representation.

Uploaded by

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

Binary Arithmetic Operations

Prof. R.EZHILARASIE
Assistant Professor
School of Computing
SASTRA Deemed to be University

Digital Logic Circuits & Microprocessors -


1
Arithmetic Operations and Binary Codes
Objectives

•To Perform arithmetic operations on binary numbers

•To Understand the representation of signed binary numbers

•To Perform the arithmetic operations on signed binary numbers

Digital Logic Circuits & Microprocessors -


2
Arithmetic Operations and Binary Codes
Binary Arithmetic
• Basics of Binary Addition, Subtraction, Multiplication and Division
Binary Addition a) 11+10 b) 111 +11

• Four Basic rules for adding binary digits

A B Sum Carry A B C Sum Carry


0 0 0 0 0 0 1 1 0

0 1 1 0 0 1 1 0 1

1 0 1 0 1 0 1 0 1

1 1 0 1 1 1 1 1 1

Digital Logic Circuits & Microprocessors -


3
Arithmetic Operations and Binary Codes
Binary Subtraction
Binary Subtraction
•Four Basic rules for subtracting binary digits a) 11 - 01 b) 101 - 011

A B Sub Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

Digital Logic Circuits & Microprocessors -


4
Arithmetic Operations and Binary Codes
Binary Multiplication
• Four Basic rules for multiplying binary digits a) 11 * 10 b) 111 * 11

A B Mul
(A * B)
0 0 0
0 1 0
1 0 0
1 1 1

Digital Logic Circuits & Microprocessors -


5
Arithmetic Operations and Binary Codes
Binary Division
• Similar to decimal division
• Called as the long division procedure a) 110 / 10

Digital Logic Circuits & Microprocessors -


6
Arithmetic Operations and Binary Codes
Signed Binary Numbers (SBN)
• Digital Systems able to handle both Positive and Negative Numbers
• Signed Binary Numbers consists of
– Sign: Positive/ Negative
– Magnitude: Value of the Number

• Signed Numbers represented in three forms:


– Sign magnitude

– 1’ Complement

– 2’s Complement

Digital Logic Circuits & Microprocessors -


7
Arithmetic Operations and Binary Codes
Signed Binary Numbers: Representation
Sign Magnitude
•Negative Number has the same magnitude bits as positive number but the sign bit is 1 rather zero
•Eg: - 20

1’s Complement Form


•Negative Number is the 1’s complement of the corresponding positive Number
•1’s complement:
– Changing all 1s to 0s and all 0s to 1s
•Ex: - 20

2’s Complement Form


•Negative Number is the 2’s complement of the corresponding positive Number
•2’s complement:
– Found by adding 1 to the LSB of the 1’s complement
– 2’s complement = (1’s complement ) +1
•Ex: - 20
Digital Logic Circuits & Microprocessors -
8
Arithmetic Operations and Binary Codes
Example
• Express – 12 as an 8-bit number in a)sign magnitude b)1’s complement
c) 2’s complement

Digital Logic Circuits & Microprocessors -


9
Arithmetic Operations and Binary Codes
Example
• 2’s Complement are mostly used in Computers and microprocessor based systems
• Determine the decimal values of SBN in 2’ s Complement Form
• Eg: a) 01010111 b) 11010111

Digital Logic Circuits & Microprocessors -


10
Arithmetic Operations and Binary Codes
Arithmetic operations with Signed Binary Numbers
• Addition
– Addition of two positive numbers yields a positive number
Ex: 00001000 + 00001010

– Addition of positive number and a smaller negative number yields a positive number
Ex: 10 - 3

Digital Logic Circuits & Microprocessors -


11
Arithmetic Operations and Binary Codes
SBN: Addition
• Addition of positive number and a larger negative number yields a negative number in 2’s
complement form
Ex: 4 – 8

Digital Logic Circuits & Microprocessors -


12
Arithmetic Operations and Binary Codes
SBN: Subtraction
• To subtract 2 SBN, take the 2’s Complement of the subtrahend and add.
Discard any final carry bit.
• Eg: a) 8 – 3

Digital Logic Circuits & Microprocessors -


13
Arithmetic Operations and Binary Codes
Summary
• Binary Arithmetic Operations

• Signed Binary Numbers

• Representation of SBN

• Arithmetic operations on SBN

Digital Logic Circuits & Microprocessors -


14
Introduction to Digital Concepts
Thank You

Digital Logic Circuits & Microprocessors -


15
Introduction to Digital Concepts
Digital Logic Circuits & Microprocessors -
16
Introduction to Digital Concepts
Binary Codes
• Digital data is represented, stored and transmitted as groups of binary digits
• Group of bits : Binary Codes
– represent numbers, alphabets as well as special characters

• Process of assigning a group of binary digits to represent multivalued items of information


• Ex: 01000001 Decimal (65) : BCD (41) : Alphabet A (ASCII code)
• Codes are also used for Error detection and error correction in digital systems
• Classified into:
– Numeric Codes
• Weighted Codes
• Non Weighted Codes
– Alphanumeric Codes
– Error Detecting Codes

Digital Logic Circuits & Microprocessors -


17
Arithmetic Operations and Binary Codes
Numeric Codes: Weighted Codes
Decimal 8421 2421 84-2-1
• Positional weighting principles ie., each position of a number represent a
0 0000 0000 0000 specific weight

1 0001 0001 0111 • Eg: 8421, 2421,5421,5211 (Positive Codes)

2 0010 0010 0110 • 84-2-1, 74-2-1 (Negative Codes)


3 0011 0011 0101
4 0100 0100 0100
5 0101 1011 1011
6 0110 1100 1010
7 0111 1101 1001
8 1000 1110 1000
9 1001 1111 1111

Digital Logic Circuits & Microprocessors -


18
Arithmetic Operations and Binary Codes
Numeric Codes: Non-Weighted Codes
Decimal BCD Excess-3
• Not positionally weighted ie., each position within a binary number is
Code
not assigned a fixed value
0 0000 0011
• Eg: Excess-3 codes and Gray codes
1 0001 0100

2 0010 0101 • Excess-3 Code

3 0011 0110 – Obtained from the corresponding binary value plus three

4 0100 0111

5 0101 1000

6 0110 1001

7 0111 1010

8 1000 1011

9 1001 1100
19
Binary to Gray Code
Decimal Binary Gray Code

0 0000 0000 • One bit changes when going from one number to next
1 0001 0001 • Binary To Gray Code Conversion
2 0010 0011 – MSB of Gray code is same as Binary number
3 0011 0010 – Perform EX-OR operation between the adjacent pair of binary codes bits from left
to right
4 0100 0110

5 0101 0111

6 0110 0101

7 0111 0100

8 1000 1100

9 1001 1101

10 1010 1111

11 1011 1110

12 1100 1010

13 1101 1011

14 1110 1001

15 1111 1000

Digital Logic Circuits & Microprocessors -


20
Arithmetic Operations and Binary Codes
Gray to Binary Code
Decimal Gray Binary Code
0 0000 0000 • MSB of Binary code is same as Gray code
1 0001 0001 • Perform EX-OR operation between the bit just written and the next
2 0011 0010 gray code bit
3 0010 0011
4 0110 0100
5 0111 0101
6 0101 0110
7 0100 0111
8 1100 1000
9 1101 1001
10 1111 1010
11 1110 1011
12 1010 1100
13 1011 1101
14 1001 1110
15 1000 1111
Digital Logic Circuits & Microprocessors -
21
Introduction to Digital Concepts
Alphanumeric Codes
• Represent alphabet and other symbols as a series of 1’s and 0’s
• Eg: ASCII – American Standard Code for Information Interchange
EBCDIC – Extended Binary Coded Decimal Interchange Code
ASCII Code
• 7-bit code
• 128 characters can be represented
• 94 graphic ( 26(A-Z),26(a-z),10 (0-9) and 32 printable (like !,*,%,$)
• 34 non-printing characters
EBCDIC code
• 8-bit code
• 128 characters can be represented
• 92 graphic ( 26(A-Z),26(a-z),10 (0-9) and 30 printable (like !,*,%,$)
• 49 non-printing characters

Digital Logic Circuits & Microprocessors -


22
Introduction to Digital Concepts
Letter ASCII Code Binary Letter ASCII Code Binary Number ASCII Code Binary
a 97 1100001 A 65 1000001 0 48 00110000
b 98 1100010 B 66 1000010 1 49 00110001
c 99 1100011 C 67 1000011 2 50 00110010
d 100 1100100 D 68 1000100 3 51 00110011
e 101 1100101 E 69 1000101 4 52 00110100
f 102 1100110 F 70 1000110 5 53 00110101
g 103 1100111 G 71 1000111 6 54 00110110
h 104 1101000 H 72 1001000 7 55 00110111
i 105 1101001 I 73 1001001 8 56 00111000
j 106 1101010 J 74 1001010 9 57 00111001
k 107 1101011 K 75 1001011
l 108 1101100 L 76 1001100
m 109 1101101 M 77 1001101
n 110 1101110 N 78 1001110
o 111 1101111 O 79 1001111
p 112 1110000 P 80 1010000
q 113 1110001 Q 81 1010001
r 114 1110010 R 82 1010010
s 115 1110011 S 83 1010011
t 116 1110100 T 84 1010100
u 117 1110101 U 85 1010101
v 118 1110110 V 86 1010110
w 119 1110111 W 87 1010111
x 120 1111000 X 88 1011000
y 121 1111001 Y 89 1011001
z 122 1111010 Z 90 1011010

ASCII Chart 23
Error Detection and Correction Codes
• Error Detection : Parity Generator and Checker
• Error Correction: Hamming Code
Error Detection: Parity Generator and Checker
• Error in any bit can cause a problem
• Parity: System that checks for errors in a multi-bit binary number by counting the number
of 1’s
• Parity bit: Bit appended to a binary number to make the number of 1’s even or odd
– Even parity: requires binary number to have an even number of ones
– Odd parity: requires binary number to have an odd number of ones
Odd Parity Generator
Parity Bit Data Total Number of 1’s
0 0001110 3
1 0011000 3
1 0010100 3
0 1011101 5
24
Summary
• Binary Arithmetic Operations

• Signed Binary Numbers

• Representation of SBN

• Arithmetic operations on SBN

• Binary Codes

Digital Logic Circuits & Microprocessors -


25
Introduction to Digital Concepts
Thank You

Digital Logic Circuits & Microprocessors -


26
Introduction to Digital Concepts

You might also like