0% found this document useful (0 votes)
28 views

02 Lesson2

This document discusses computer arithmetic and binary number representations. It covers basic binary arithmetic operations like addition, subtraction, multiplication, and division. It also describes different methods for representing signed integers in binary, including sign-magnitude, one's complement, and two's complement representations. Two's complement is commonly used in computers because it simplifies subtraction. The document provides examples of performing arithmetic operations and representing positive and negative numbers using different signed binary methods. It concludes with self-assessment exercises for students to practice binary arithmetic and number representations.

Uploaded by

Deelaka Ransilu
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)
28 views

02 Lesson2

This document discusses computer arithmetic and binary number representations. It covers basic binary arithmetic operations like addition, subtraction, multiplication, and division. It also describes different methods for representing signed integers in binary, including sign-magnitude, one's complement, and two's complement representations. Two's complement is commonly used in computers because it simplifies subtraction. The document provides examples of performing arithmetic operations and representing positive and negative numbers using different signed binary methods. It concludes with self-assessment exercises for students to practice binary arithmetic and number representations.

Uploaded by

Deelaka Ransilu
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/ 6

Degree of Bachelor of Information Technology 1

Lesson 2 - Computer Arithmetic

Learning Outcomes
By the end of this lesson, students will be able to;

• apply basic arithmetic operations.

• describe two’s complement in integer representation.

• describe sign-magnitude representation.

• describe floating point representation mechanism.

• compute arithmetic operations using integers and floating point numbers.

2.1 Binary Arithmetic


We are familiar with different arithmetic operations such as addition, subtraction, multiplica-
tion and division in a decimal system. Arithmetic in a computer are done using binary numbers
and it is similar to the decimal arithmetic.
The sum of two binary numbers is calculated by the same rules as in decimal, except that
the digits of the sum in any significant position can be only 0 or 1 . Any carry obtained in a given
significant p osition i s u sed by t he p air o f d igits o ne s ignificant po sition hi gher. Su btraction is
slightly more complicated. The rules are still the same as in decimal, except that the borrow in
a given significant p osition adds 2 to a minuend d igit. Multiplication is s imple: The multiplier
digits are always 1 or 0: therefore, the partial products are equal either to the multiplicand or
to 0. The rules of binary arithmetic operations are shown in Figure 2.1.

Figure 2.1: The rules of binary arithmetic

1
2 ITE 1812 - Mathematic for IT

Example 2.1
Add the binary numbers 110010 and 110111.

Solution.

Example 2.2
Subtract the binary numbers 101101 and 100111.

Solution.

Example 2.3
Multiply the binary numbers 1011 and 101.

Solution.

2
Degree of Bachelor of Information Technology 3

Example 2.4
Divide the binary numbers 11001 and 101.

Solution.

Therefore the answer is 101.

2.2 Signed Binary Numbers


In tradition we use the ‘+’ sign before a number to indicate it as a positive number and a
‘-’ sign to indicate it as a negative number. This method of representation of numbers is
called sign-magnitude representation. However, on a computer this + and − representation
is not convenient. Hence computer use three different techniques to denote signed binary
numbers. They are sign-magnitude representation, one’s-complement representation and two’s-
complement representation.

2.2.1 Sign-Magnitude Representation


In this representation we use an additional bit to denote the sign of the number. This additional
bit is called as the sign bit. The sign bit is usually placed as the MSB. Generally we replace
“+” sign with “0” and “-” with “1”. For instance, an 8-bit signed binary number 01100101
represents a positive number whose magnitude is (1100101)2 = (101)10 . In the given number
01100101 MSB is 0, which indicates that the number is positive. Further, in the signed binary
form, 11100101 represents a negative number whose magnitude is (1100101)2 = (101)10 . The 1
in the MSB position indicates that the given number is negative.

2.2.2 One’s Complement Representation


One’s complement operation is very simple to carry out. Using one’s complement representa-
tion, the positive numbers are directly represented by their equivalent binary form. To find
the one’s complement of a negative number convert all of the 1’s in the number to 0’s, and all
of the 0’s to 1’s. Then add the sign bit. Therefore, in the one’s complement representation
the leftmost bit is 0 for positive numbers and 1 for negative numbers, as it is for the signed
magnitude representation. The process of changing 1’s to 0’s and changing 0’s to 1’s, is called
as complementing the bits.

3
4 ITE 1812 - Mathematic for IT

Example 2.5

(a) What is the one’s complement binary representation of decimal number −75?

(b) What is the one’s complement binary representation of decimal number 11?

Solution.

(a) Binary value of 75 = 1001011


Complement of 1001011 = 0110100
One’s complement of −75 = 10110100

(b) Binary value of 11 = 1011


One’s complement of 11 = 1011

2.2.3 Two’s Complement Representation


Using two’s complement representation, the positive numbers are directly represented by their
equivalent binary form. For the negative numbers, add 1 to the one’s complement of the
corresponding number.

Example 2.6

(a) What is the two’s complement binary representation of decimal number −75?

(b) What is the two’s complement binary representation of decimal number 11?

Solution.

(a) Binary value of 75 = 1001011


Complement of 1001011 = 0110100
One’s complement of −75 = 10110100
Two’s complement (add 1) = + 1
Two’s complement of −75 = 10110101

(b) Binary value of 11 = 1011


Two’s complement of 11 = 1011

2.3 Subtract with Two’s Complement


Two’s complement is used in digital computers to simplify the subtraction operation. The
subtraction of two positive numbers (M − N ), both of base 2, can be done as follows:

1. Add minuend M to the two’s complement of the subtrahend N .

2. Inspect the result obtained in step 1 for an end carry.

(a) If an end carry occurs discard it.

4
Degree of Bachelor of Information Technology 5

(b) If an end carry does not occurs, take the two’s complement of the number obtained
in step 1 and place a negative sign in front.

Example 2.7
Using two’s complement do the following subtraction.

(a) 17 − 10

(b) 26 − 75

Solution.

(a) Binary value of 17 = 10001


Two’s complement of −10 = + 10110
= 100111
End carry = 1
Result (Discard end carry) = 00111

(b) Binary value of 26 = 00011010


Two’s complement of −75 = + 10110101
= 11001111
Therefore no carry bit
Two’s complement of 11001111 = 110001
Therefore result is -110001.

Self-Assessment Exercises
1. Do the following binary arithmetics.

(a) 1101.01 + 101.01


(b) 110001.110 − 10111.010
(c) 110001.11 × 101.1
(d) 1101.1 × 11.1
(e) 10111.110/1011.11

2. Give the representation of the following negative numbers on a computer using two’s
compliment.

(a) −19710
(b) −198710
(c) −4932110

5
6 ITE 1812 - Mathematic for IT

3. Using two’s compliment do the following subtractions.

(a) 29 − 12
(b) 9457 − 6785
(c) 5830 − 876

Suggested Reading
Chapter 19: William Stallings, (2010) Computer Organization and Architecture: Designing for
Performance, 9th Edition, Prentice Hall.

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