0% found this document useful (0 votes)
31 views15 pages

MC - Lecture Slides - 03 Computer Arithmetic

This document discusses binary arithmetic operations including addition, subtraction, multiplication, and division. It provides examples of performing each operation in binary and converting the results to decimal. It also covers binary complements, overflow, underflow, and negative number representations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views15 pages

MC - Lecture Slides - 03 Computer Arithmetic

This document discusses binary arithmetic operations including addition, subtraction, multiplication, and division. It provides examples of performing each operation in binary and converting the results to decimal. It also covers binary complements, overflow, underflow, and negative number representations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Mathematics for Computing (IT1030)

Lecture 3.2 -
Computer
Arithmetic
Introduction

• Recap:
• Binary numbers are a number system with base 2.
• Information represented inside a computer takes
binary values.
• Previous lecture dealt with the conversions
between different number systems.

• This lecture deals with basic mathematical


operations (such as addition, subtraction,
multiplication and division) for binary
numbers.
06/02/2017 2
Binary Addition

• Addition in the decimal number system.


• Add values rightmost position (least significant).
• If this addition is grater than 10, 1 is carried to the
2nd position and added.
• This process is carried for all the positions.

• Binary addition follows the same set of rules.


• If the addition is greater that 2, 1 is carried to the
2nd next position.

06/02/2017 3
Examples

• Evaluate the following.


• 1012 + 1012
• 000110102 + 000011002
• 10001 + 11101
• 1110 + 1111
• 101101 + 11001
• 10111 + 110101
• 1011001 + 111010
• 11011 + 1001010
• Compare the above results by converting them to
decimal
06/02/2017
numbers. 4
Binary Subtraction

• Similar to subtraction in the decimal number


system.
• Inverse of addition.
• If the values cannot be subtracted, borrow
from the next position.
• Subtraction table,
• 0−0=0
• 1−0=1
• 1−1=0
• 0 − 1 = 1 with a borrow of 1.
06/02/2017 5
Examples

• Evaluate the following.


• 10110 − 10010
• 1011011 − 10010
• 100010110 − 1111010
• 1010110 − 101010
• 101101 − 100111
• 1000101 − 101100
• 1110110 − 1010111
• Compare the above results by converting
them
06/02/2017
to decimal numbers. 6
Multiplication &
Division
• Similar to multiplication and division in the
decimal number system.
• Rules of binary multiplication,
• 0×0=0
• 0×1=0
• 1×0=0
• 1 × 1 = 1.
• Rules of binary division,
• 0÷1=0
• 1 ÷ 1 = 1.
06/02/2017 7
Examples

• Evaluate the following.


• 1100 × 1010
• 1111 × 101
• 0011 × 11
• 1100110 × 1000
• 1000 ÷ 10
• 1010 ÷ 11
• 1111 ÷ 111
• Compare the above results by converting
them
06/02/2017
to decimal numbers. 8
Self studying

• How these values are represented in a computer.


• How much space each value takes when storing.
• What happens if a binary operation provides a
result which exceeds the allocated space
(Overflow)?
• What happens if an operation provides a result
that is too small for the allocated space
(Underflow)?
• How are negative numbers represented in a
computer?
06/02/2017 9
Complimentary
Arithmetic
• Complements are used in digital computers
for simplifying,
• the subtraction operation
• the logical manipulation.
• Two types of compliments for each base 𝑏
system.
• 𝑟’𝑠 compliment
• (𝑟 − 1)’𝑠 compliment
• Example: For binary numbers, 2’s complement and
1’s complement.
06/02/2017 10
Complimentary
Arithmetic (cont'd.)
• Given a number 𝑁 in base 𝑟 having 𝑛 digits,
(𝑟 − 1)’s complement of 𝑁,
𝑁′ = 𝑟𝑛 − 1 − 𝑁
• Given a number 𝑁 in base 𝑟 having 𝑛 digits, 𝑟’s
complement of 𝑁,
𝑁 ′ = 𝑟 𝑛 − 𝑁 for 𝑁 ≠ 0; 0 otherwise

• Comparing (𝑟 − 1)’s compliment, 𝑟’s


compliment can be obtained by adding 1 to
the (𝑟 − 1)’s compliment.
06/02/2017 11
Examples

• Obtain 9’𝑠 compliment and 10’𝑠 compliment of


246700.

• Get the 1’𝑠 and 2’𝑠 compliments of the


following binary numbers.
• 1100011
• 0001111
• 1010100
• 1111011
06/02/2017 12
06/02/2017 13
Summary

• Students should be able to,


• Perform basic binary operations (addition,
subtraction, multiplication and division).
• Explain overflow and underflow.
• Explain how signs works in binary representations
in a computer.
• To perform complement operations (r’s
complement and (r-1)’s complement.

06/02/2017 14
End of Lecture 3.2

Next Lecture:-
Differentiation

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy