Professional Documents
Culture Documents
Computer Arithmetic
Computer Arithmetic
Objectives:
• To understand different data/information
representation methods.
• Word Length:
• A word --is a unit of information of some fixed length n.
– n bit word allows up to 2n different items to be represented .
– e.g. with n=4, we can encode the 10 decimal digits as-
0=0000 1=0001 2=0010 3=0011 4=0010 5=0101 6=0110
7=0111 8=1000 9=1001
Data
Instruction
(operands)
Numbers Non-
numerical
(Numerical) data (string)
Floating
Fixed Point
Point
Binary
Decimal Binary Decimal
(0 or 1)
CO52 33
CO53 44(LSB)
Note: Byte 0,3 indicates MS byte of the W0
Byte 0,0 indicates LS byte of the W0
Data Storage Order:
• Little endian byte:
– It is named because LS Byte of the word is assigned to lowest
address and MS Byte of the word is assigned to higher address.
• Fixed point
– has a fixed number of digits .
– Allow a limited range of values
• Binary numbers:
Binary numbers:
• Is a positional weighted system
• Base is 2
• e.g.1011.101
1 23 0 2 2 1 21 1 2 0 1 2 1 0 2 2 1 2 3
8+0+2+1+0.5+0+0.125 = (11.625)10
Signed numbers:
Sign Magnitude
Basic format:
– Structure of floating point (Real ) number is as follows—
–
1.0 x 1018
1.0 x 1018, M x BE
Exponent
M=1.0
Mantissa
E=18
Base B=10
• Only mantissa and exponent are stored. The base is implied(known already)
Floating point numbers:
• The same floating point no can be represented in
more than one way.
– e.g.
1.0 x 1018 can be represented as---
0.1 x 1019
1000000 x 1012
0.000001 x 1024
• Normalization:
– A number with no leading 0’s is called a Normalized Number.
– i.e. putting decimal(radix) point after first nonzero digit .
1.0 x 1018 ----unique normalized form
• Biasing:
• In floating-point arithmetic, a biased exponent is the result of
adding some constant (called the bias) to the exponent
chosen to make the range of the exponent nonnegative.
• To deal with this problem, IEEE has sponsored a standard for 32bit and 64 bit
floating point numbers known as IEEE754 standard.
S Exponent Mantissa
1 10000000 (8 bit)=0xC02CC
010110011……………….00(23 bit)
For 64 bit format
S Exponent Mantissa
1 10000000000 (11 bit) 010110011000……………….00 (52 bit)
• e.g Convert –(105.625) to IEEE 754, single precision and double
precision floating point format
1. Sign= -ve, S=1;
2. (105.625)10= (1101001.101)2
3. Shift decimal point to left by 6 bit (first nonzero digit)
105.625=1.101001101x26
4. Biased exponent E=e+127 =6+127=(133)10= (10000101)2
5. Represent in IEEE 754 ,32 bit format
S Exponent Mantissa
1 10000101 (8 bit) 101001101……………….00(23 bit)
= 0xC2D3400
IEEE754 to decimal conversion:
convert following IEEE 754 floating point format to
decimal.
S Exponent Mantissa
1 10000000 (8 bit) 010110011……………….00(23 bit)
1. Serial adder
2. Basic adders:
– Half adders:
– Full Adder
– Subtractor
.
Serial adder
• Is a circuit used for adding n bit
binary numbers.
Truth Table:
A B Sum(S) Carry(C)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Circuit diagram:
Full Adder:
Block Diagram:
Truth Table:
Carry
A B Cin Sum(S)
(Cout)
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
S=ABCin
Circuit diagram:
Parallel adders:
• Circuits that adds all the bits of two n-
bit numbers as well as Cin(carry) in one
clock cycle are called n–bit parallel
adders.
• Initially Cin=0
• Disadvantages:
– Amount of hardware increases
linearly with n.
4 bit 2’s complement adder-subtractor
High speed adder:
• Why to design fast adders:
– To reduce time required to form carry signals.
e.g. Y=Multiplicand
X= Multiplier
• To compute Y x X is to add the multiplicand Y to
itself X(multiplier) times.