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

Lecture#6

The document discusses various arithmetic operations in different number systems including decimal, binary, octal and hexadecimal. It explains how to perform addition and subtraction in each number system by padding numbers with zeros, lining them up and carrying or borrowing values between columns.

Uploaded by

nauman khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Lecture#6

The document discusses various arithmetic operations in different number systems including decimal, binary, octal and hexadecimal. It explains how to perform addition and subtraction in each number system by padding numbers with zeros, lining them up and carrying or borrowing values between columns.

Uploaded by

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

Object Oriented Programming (CSC241 )

Introduction to ICT

NUMBER SYSTEM
ARITHMETIC

Lecture#6

COMSATS University Islamabad, Abbottabad Campus


TABLE OF CONTENTS

Arithmetic operations
 Addition of Decimal
 Subtraction of Decimal
 Addition of Binary
 Subtraction of Binary
 Addition of Octal
 Subtraction of Octal
 Addition of Hexadecimal
 Subtraction of Hexadecimal

Tutor::Dr. Malik Adnan Jaleel COMSATS University Islamabad Abbottabad Campus 2


ARITHMETIC OPERATION

 Arithmetic includes the basic arithmetic operations of addition, subtraction,


multiplication and division.
 We will discuss two arithmetic operations in different number systems
 Addition
 Subtraction

COMSATS University Islamabad Abbottabad Campus 3


ADDITION OF DECIMAL

 Addition of decimals is performed using the following steps:


 Step 1: The numbers are first padded with zero depending upon the maximum
digits present after the decimal for any of the numbers.
 For example, while adding 3.456 to 7.1, since the number 3.456 has the number of digits
after the decimal, the padding is done according to 3.456. Since 3.456 has 3 digits after
the decimal, we pad two zeros after 1. So, 7.1 to three places is 7.100.
 Step 2: The numbers are lined up vertically along with each other as given in the
below figure.

COMSATS University Islamabad Abbottabad Campus 4


CONT…

 Step 3: Finally, add the decimal numbers similar to integers and place the decimal point
accordingly.

 Example: Addition 0.0075 + 5.


Solution: padding with zero
0.0075
5.0000
Lining up the decimal
0.0075
5.0000
Addition 5.0075

COMSATS University Islamabad Abbottabad Campus 5


SUBTRACTION OF DECIMAL

 Subtraction of decimals is performed using the following steps:


 Step 1: The numbers are first padded with zero depending upon the maximum
digits present after the decimal for any of the numbers.
 For example, while subtracting 3.456 from 7.1, since the number 3.456 has more digits
after the decimal, the padding is done according to 3.456. Since 3.456 has 3 digits after
the decimal, we pad 7.1 to three places as 7.100.
 Step 2: The numbers are lined up vertically along with each other as shown below.

COMSATS University Islamabad Abbottabad Campus 6


CONT…

 Step 3: Finally, subtract the decimal numbers similar to integers and place the decimal
point accordingly.

 Example:7.304 – 1.15
Solution: padding with zero
7.304
1.150
Lining up the decimal
7.304
1.150
Subtraction 6.154

COMSATS University Islamabad Abbottabad Campus 7


ADDITION OF BINARY

 Binary addition is performed in the same way as addition in the decimal-system


 The addition of two binary bits generates SUM bit and CARRY bit.
 The four basic rules for adding digits are as follows:

 Example: Add (a) 111 and 101 (b) 1010, 1001 and 1101.
 a) b)

COMSATS University Islamabad Abbottabad Campus 8


SUBTRACTION OF BINARY

 Similar to decimal subtraction


 The subtraction of two binary bits generates a difference bit and borrow bit
 There are four basic rules for subtracting binary digits
Operation Result
Difference Barrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

 Perform the following subtractions. (a) 11 - 01 , (b) 11-10 (c) 100 - 011
 a) b) c)
COMSATS University Islamabad Abbottabad Campus 9
ADDITION OF OCTAL

 Addition of octal numbers is carried out by the same principle as that of


decimal or binary numbers.
 An addition table for octal numbers is given below:

COMSATS University Islamabad Abbottabad Campus 10


EXAMPLE

1. (162)8 + (537) 8 2) (25.27) 8 + (13.2) 8

COMSATS University Islamabad Abbottabad Campus 11


SUBTRACTION OF OCTAL

 subtraction of octal numbers can be performed by following the rules of subtraction


of decimal numbers.
 Borrow is equal to the base of number system.
 If you are working with base 2 you borrow 2.
 If you are working with base 8 you borrow 8.
 Example: 345)8-146)8
 1st column (units column) subtraction. 5-6
 This is not possible. You have to borrow from tens column. The number you borrow is 8. So units
column subtraction is 5+8-6
 2nd column (tens column) subtraction.
 4 becomes 3 after borrow. 3-4. To proceed this subtraction you have to borrow from hundreds
column. So tens column subtraction is 3+8-4
COMSATS University Islamabad Abbottabad Campus 12
ADDITION OF HEXADECIMAL

 Adding Hexadecimal number is same as decimal addition.


 The only difference is the added numerals A, B, C, D, E, and F.
 It may be convenient to transform the hex numbers to decimal system when the
values greater than the number 9.
 Below is an example of hex addition.

COMSATS University Islamabad Abbottabad Campus 13


CONT…

 In the example above, E + 7 in decimal is 14 + 7 = 21.


 21 in decimal is 15 in hex
 . Just like the decimal addition, the 1 carries over to the next column.
 The next column works out to be 1 + B (11) + 5 = 17 in decimal and 11 in hex.
 Carry over the 1 to the final column resulting in 1 + 6+ E (14) = 21 in decimal and 14
in hex.
 This yields the result of 1515 in hex.

COMSATS University Islamabad Abbottabad Campus 14


SUBTRACTION OF HEXADECIMAL

 Hex subtraction can be calculated in the same way as decimal subtraction


 the big difference is when borrowing in hex, the "1" that is borrowed represents
16decimal rather than 10decimal.
 This is because the column that is being borrowed from is 16 times larger in hex
than 10 in decimal.
 Below is an example of hex subtraction.

COMSATS University Islamabad Abbottabad Campus 15


CONT…

 In the first column, 7, is smaller than E, or 15 in decimal.


 So we need to borrow from next column.
 This reduces the 5, to 4, and lends 1, or 16 decimal to the first column i.e.
16decimal + 7decimal - E or 14 in decimal = 9.
 Now in second column 4 is smaller than B (11).
 So again we need to borrow from next column.
 This reduces the E, to D, and lends 1, or 16 decimal to the second column i.e.
16decimal + 4 - B or 11 in decimal = 9.
 Last column requires no borrowing, making the calculations simple, D or 13 in
decimal – 6 = 7 yielding the final result of 799.

COMSATS University Islamabad Abbottabad Campus 16


THANKS

COMSATS University Islamabad Abbottabad Campus 17

You might also like