OperationsonBits

OperationsonBits - Kingdom Of Saudi Arabia Al-Imam Muhammad...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Operations on Bits Chapter 4 in “Foundation of Computer System” Kingdom Of Saudi Arabia Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Information System Department 1 st semester, 2010 – 2011 CS 224: Computer Organization 1 T. Hala A. Al-Rumaih
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction Operation on bits can be divided in to two broad categories: 2
Background image of page 2
Arithmetic Operations It involves adding, subtracting, multiplying and dividing. All Arithmetic operations (+, -, *, /) can e applied to integers and floating-point number. Arithmetic Operations on integers: We are focusing on addition and subtraction. The multiplication operation can be implemented in software using repeated addition. The Division operation can be implemented in software using repeated subtraction. We will use the two’s complement representation because it is the only method to store integer in computer today. 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Adding in two’s Complement Adding numbers in 2’s complement is like adding the numbers in decimal, you can add column by column and if there is a carry, it is added to the next column. You should remember that you are dealing with binary digits, not decimal digits. When you add 2 bits, the result is 0 or 1 . You have to carry a 1 that is propagated to the next column. 4
Background image of page 4
Adding in two’s Complement (Cont.) Rule of Adding Integers in two’s Complement: 5 Add 2 bits and propagate the carry to the next column. If there is a final carry after the leftmost column addition, discard it. Number of 1s Result Carry None 0 - One 1 - Two 0 1 Three 1 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Adding in two’s Complement (Cont.) Ex(1): Add two numbers in two’s complement representation using 8 -bit memory location (+17) + (+22) (+39) Solution: +17 00010001 +22 00010110 (+17) + (+22) = 00100111= +39 6
Background image of page 6
Adding in two’s Complement (Cont.) Ex(2): Add 24 and -17 both numbers in two’s complement representation and using 8-bit memory location (+24) + (-17) (+7) Solution : +24 00011000 -17 “two’s complement rule with the –ve number” -17 00010001 11101111 (+24) + (-17) = 00000111= +7 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Adding in two’s Complement (Cont.) Ex(3): Add -35 and 20 both numbers in two’s complement representation and using 8-bit memory location (-35) + (+20) (-15) 8
Background image of page 8
Adding in two’s Complement (Cont.) Ex(4) : Add +127 and +3 both numbers in two’s complement representation and using 8 -bit memory location (+127) + (+3) (+130) Solution: +127 01111111 +3 00000011 (+127) + (+3) = -126 ? Error We found that the leftmost bit of the result is 1 which means the number is –ve The correct answer should be positive number +130 Overflow 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Overflow It is an error occurs when you try to store a number that is not within the range defined by the allocation. When you add numbers in 2’s complement using N bits,
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/09/2012 for the course CSCI 504 taught by Professor Jon during the Spring '11 term at IUP.

Page1 / 40

OperationsonBits - Kingdom Of Saudi Arabia Al-Imam Muhammad...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online