0% found this document useful (0 votes)
17 views36 pages

Chapter 2

The document provides an overview of computer arithmetic, focusing on number systems such as binary, octal, decimal, and hexadecimal, along with their representations and conversions. It discusses integer representation methods, including signed magnitude, one's complement, and two's complement, as well as floating-point representation and arithmetic operations like addition, subtraction, multiplication, and division. Additionally, it introduces Booth's algorithm for binary multiplication.

Uploaded by

tibebe164
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)
17 views36 pages

Chapter 2

The document provides an overview of computer arithmetic, focusing on number systems such as binary, octal, decimal, and hexadecimal, along with their representations and conversions. It discusses integer representation methods, including signed magnitude, one's complement, and two's complement, as well as floating-point representation and arithmetic operations like addition, subtraction, multiplication, and division. Additionally, it introduces Booth's algorithm for binary multiplication.

Uploaded by

tibebe164
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/ 36

Contents

Computer Arithmetic
 Integer representation
Sign-magnitude representation
One’s complements
Two’s complements
 Floating point representation
Booth algorithm
• Number systems include decimal, binary, octal and
hexadecimal
Number System Base Symbol

Binary Base 2 B

Octal Base 8 O

Decimal Base 10 D

Hexadecimal Base 16 H
2
Decimal Number System
• The number system that we use in our day-to-day life is the decimal
number system.
• Decimal number system has base 10 as it uses 10 digits from 0 to 9.
• In decimal number system, the successive positions to the left of the
decimal point represent units, tens, hundreds, thousands and so on.
• The weighted values for each position are:
10^4 10^3 10^2 10^1 10^0 10^-1 10^-2 10^-3

10000 1000 100 10 1 0.1 0.01 0.001

left of the decimal point Right of decimal point


Con...
• Each digit appearing to the left of the decimal point represents a
value between zero and nine times power of ten represented by its
position in the number.
• Digits appearing to the right of the decimal point represent a value
between zero and nine times an increasing negative power of ten.
• Example: the value 725.194 is represented in expansion form as
follows:
7 * 10^2 + 2 * 10^1 + 5 * 10^0 + 1 * 10^-1 + 9 * 10^-2 + 4 *
10^-3
=7 * 100 + 2 * 10 + 5 * 1 + 1 * 0.1 + 9 * 0.01 + 4 * 0.001
=700 + 20 + 5 + 0.1 + 0.09 + 0.004
=725.194
Binary Number System
Why Binary System?
• Most modern computer system using binary logic. And made of a
series of switches
• Each switch has two states: ON or OFF
• Each state can be represented by a number 1 for “ON” and 0 for
“OFF”
• The computer represents values(0,1) using two voltage levels
(usually 0V for logic 0 and either +3.3 V or +5V for logic 1).
• The Binary Number System uses base 2 includes only the digits 0 and
1
• The weighted values for each position are :
5
Octal System
 Computer scientists are often looking for shortcuts to do
things
 One of the ways in which we can represent binary
numbers is to use their octal equivalents
 This is especially helpful when we have to do fairly
complicated tasks using numbers
The octal numbering system includes eight base digits (0-7)
Also known as the Base 8 System
Readily converts to binary
Groups of three (binary) digits can be used to represent
each octal digit
Also uses multiplication and division algorithms for
conversion to and from base 10
Hexadecimal number system
• Base 16 system
• Uses digits 0-9 & letters A,B,C,D,E,F
• Groups of four bits represent each base 16 digit
Number Base Conversion
Binary to Decimal:
• Multiply each digit by its weighted position, and add
• each of the weighted values together or use expansion form
directly.
Example
The binary value 1100 1010 represents :
1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 + 1*2^3 + 0*2^2 +
1*2^1 + 0*2^0
=1 * 128 + 1 * 64 + 0 * 32 + 0 * 16 + 1 * 8 + 0 * 4 + 1
*2+0*1
= 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0
=202
Decimal to Binary
There is a common method, that may be used to convert from integer
number in decimal form to binary form:
Repeated Division By 2
For this method, divide the decimal number by 2,
If the remainder is 0, on the right side write down a 0.
If the remainder is 1, write down a 1.
When performing the division, the remainders which will represent
the binary equivalent of the decimal number are written beginning at
the least significant digit (right) and each new digit is written to more
significant digit (the left) of the previous digit.
Example: Convert the number 333 to binary.
Division Quotient Remainder Binary
333/2 166 1 1
166/2 83 0 01
83/2 41 1 101
41/2 20 1 1101
20/2 10 0 01101

10/2 5 0 001101
5/2 2 1 1001101
2/2 1 0 01001101
1/2 0 1 101001101
10
Converting Binary to Octal
start
100011001010012
Step 1: Take the binary number and from right to
left, group all placeholders in triplets. Add leading
zeros, if necessary:

010 001 100 101 001

11
0010 001 100 101 0012 = 214518

Step 2: Convert each triplet to its single-digit octal


equivalent. (HINT: For each triplet, the octal
conversion is the same as converting to a decimal
number):
010 001 100 101 001
2 1 4 5 1
12
Converting Octal to Binary
435208 = 1000111010100002
Step 1: Take each octal digit and convert each
digit to a binary triplet. Keep leading zeros:
4 3 5 2 0
100 011
0 101 010 000
0
Step 2: Combine all left to write
This will give 1000111010100002

13
Decimal-Octal:
4497810 to Octal
Repeated Division By 8
Division Quotient Remainder Binary
44978 / 8 5622 2 2

5622 / 8 702 6 62

702/8 87 6 662

87/8 10 7 7662

10/8 1 2 27662

1/8 0 1 127662
Decimal to hexadecimal
Convert 83010 to its hexadecimal equivalent:

830 / 16 = 51 R14
51 / 16 = 3 R3
3 / 16 = 0 R3

33E16
Convert Hex to Binary
• For each of the Hex digit write its binary
equivalent (use 4 bits to represent)
• Example
Convert 25A0 to binary

0010 0101 1010 0000


Computer Arithmetic
• Because electronic logic deals with currents that are on or off, it
has been found convenient to represent quantities in binary form
to perform arithmetic on a computer.
• Instead having ten different digits, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9,
in binary arithmetic, there are only two different digits, 0 and 1,
and when moving to the next column,
• Instead of the digit representing a quantity that is ten times as
large, it only represents a quantity that is two times as large.
• Integer representation
• The set { . . . , –3, –2, –1, 0, 1, 2, 3, . . . } of integers is also
referred to as signed numbers.
• The most straightforward representation of integers consists of
attaching a sign bit to any desired representation of natural
numbers, leading to signed magnitude representation.
• The standard convention is to use 0 for positive and 1 for
negative and attach the sign bit to the left end of the magnitude.
How to represent Signed Numbers?
• Plus and minus signs used for decimal numbers: 25 or +25, -16 or +16,
etc.
• For computers, it is desirable to represent everything as bits.
• Three types of signed binary number representations:
Signed magnitude,
1’s complement, and
2’s complement
Signed magnitude,
Look at the sign bit and magnitude of 18&-18

000100102 = 1810
100100102 = -1810
Sign bit Magnitude
Sign bit Magnitude
Left most bit is sign bit
0 means positive
1 means negative
+18 = 00010010
 -18 = 10010010
One’s Complement Representation
• The one’s complement of a binary number involves inverting all
bits.
• To find negative of 1’s complement number take the 1’s
complement of whole number including the sign bit.
000011002 = 1210 111100112 = -1210
Sign bit Magnitude Sign bit 1’complement
• Two’s Complement Representation
• The two’s complement of a binary number involves inverting all
bits and adding 1.
• To find the negative of a signed number take the 2’s complement
of the positive number including the sign bit.
000011002 = 1210 111101002 = -1210

Sign bit Magnitude Sign bit 2’s complement


Floating point representation
• Most of today’s computers are equipped with specialized hardware
that performs floating-point arithmetic with no special
programming required
• Floating-point numbers allow an arbitrary number of decimal places
to the right of the decimal point.
For example: 0.5  0.25 = 0.125
• They are often expressed in scientific notation.
For example:
0.125 = 1.25  10-1
5,000,000 = 5.0  106
• Computers use a form of scientific notation for floating-point
representation
• Numbers written in scientific notation have three components:

• Computer representation of a floating-point number consists of


three fixed-size fields
• This is the standard arrangement of these fields
• The one-bit sign field is the sign of the stored value.
• The size of the exponent field determines the range of values that
can…
be represented.
• The size of the significand determines the precision of the
representation.
Take as the floating-point number is 14 bits in length
oThe sign filed is one bit
oThe exponent field is 5 bits
oThe significand field is 8 bits
• The significand is always preceded by an implied binary point.
• Thus, the significand always contains a fractional binary value.
• The exponent indicates the power of 2 by which the significand is
multiplied.
Example: Express 3210 in the simplified 14-bit floating-point model.
• We know that 32 is 25. So in (binary) scientific notation 32 = 1.0 x 25 = 0.1 x
2 6.
• In a moment, we’ll explain why we prefer the second notation
versus the first.
• Using this information, we put 110 (= 610) in the exponent field and 1 in the
significant as shown.
Arithmetic operations on binary
number system
In computer system there are a number of arithmetic like
Addition
Subtraction
Division
Multiplication
Binary Addition
+ 0 1
•0+0=0
•0+1=1
•1+0=1 0 0 1
• 1 + 1 = 10
1 1 10

27
Subtraction of binary number system
Consider the subtraction of (-6) - (-13) = +7.
• In binary with eight bits this is written as 11111010 - 11110011.
• The subtraction is changed to addition by taking the 2’s
complement of the subtrahend (-13) to give (+13).
• In binary this is 11111010 + 00001101 = 100000111.
• Removing the end carry, we obtain the correct answer 00000111
(+ 7).
Division of binary number system
example 74 ÷ 8
1 0 0 1 Quotient

Divisor 1 0 0 0 1 0 0 1 0 1 0 Dividend

- 1 0 0 0

1 0

1 0 1

1 0 1 0

- 1 0 0 0

1 0 Remainder
29
Multiplication of binary number system
• The simplest machine multipliers are designed to follow a
variant of the pencil-and-paper multiplication algorithm:
…Example 8X9=72
Booth’s Algorithm
• The second method for binary multiplication
Is called Booth’s algorithm
• Possible arithmetic actions:
00  no arithmetic operation
01  add multiplicand to left half of product
10  subtract multiplicand from left half of product
11  no arithmetic operation
Example
• Therefore the answer is the combination of the A and Q column at
the fourth cycle which is 00010101

You might also like