COA-Unit 3 Computer Arithmatic
COA-Unit 3 Computer Arithmatic
Sum = a EX OR b
Carry = a AND b
The arithmetic and logic Unit
• 1. Truth table are developed
• 2. Boolean Equations are formed .
• 3. Boolean equations are implemented using logic gates.
The arithmetic and logic Unit
• An 8-bit word can represent the numbers from 0 to 255, such as,
00000000 = 0
00000001 = 1
00101001 = 41
10000000 = 128
Integer representation:
• Then How to represent NEGATIVE numbers in computer ?
• All of which involve treating the most significant (leftmost) bit in the
word as a sign bit.
• If the sign bit is 0, the number is positive; if the sign bit is 1, the number
is negative.
SIGNED-MAGNITUDE representation
• The simplest form of representation that employs a sign bit is the
sign-magnitude representation.
• In an n-bit word, the leftmost bit (MSB) bits hold the Sign and
remaining bits holds the magnitude of the integer.
Drawbacks of sign-magnitude representation:
• Addition and subtraction require a consideration of both the signs of
the numbers and their relative magnitudes to carry out the required
operation.
• There are two representations of 0
• Now, for a negative number A(A < 0), the sign bit, a n-1 is one.
• The remaining n - 1 bits can take on any one of 2 n-1 values. Therefore, the range of
negative integers that can be represented is from -1 to - 2n-1
• Example,
• If n=4, then negative number will be from 1000 to 1111(-8,-7,-6,-5,-4,-3,-2,-1).
• If n=3, then negative number will be from 100 to 111(-4,-3,-2,-1).
Two’s Complement Representation
• A Sign Bit
• An Exponent
Floating • Mantissa (“Significand”), which is assumed to be
1.xxxxx (thus, one bit of the mantissa is implied as
Point 1)
• This is called a normalized representation
Two representations
• Single precision (32-bit)
• Double precision (64-bit)
IEEE Floating-Point Format
single: 8 bits single: 23 bits
double: 11 bits double: 52 bits
S Exponent Fraction
Smallest value
Single- • Exponent: 00000001
Actual/True exponent = 1 – 127 = –126
Precision • Fraction: 000…00 means significand = 1.000….0000
• ±1.0 × 2–126
Range
Largest value
• exponent: 11111110
Actual/True exponent = 254 – 127 = +127
• Fraction: 111…11 means significand ≈ 2.0
• ±2.0 × 2+127
• Exponents 0000…00 and 1111…11 reserved
• Smallest value
– Exponent: 00000000001
actual/True exponent = 1 – 1023 = –1022
Double-Precision – Fraction: 000…00 significand = 1.0
– ±1.0 × 2–1022
Range • Largest value
– Exponent: 11111111110
actual/True exponent = 2046 – 1023 = +1023
– Fraction: 111…11 significand ≈ 2.0
– ±2.0 × 2+1023
Representation of Floating Point
Numbers
• IEEE 754 single precision
31 30 23 22 0
Floating-Point Example
Consider a 4-digit decimal example
• 1.002 × 102
Now consider a 4-digit binary example
•
3. Normalize the sum, either shifting right and
incrementing the exponent or shifting left
and decrementing the exponent
Overflow or Yes
underflow?
No Exception
No
Still normalized?
Yes
Done
Floating point Multiplication
•
Floating point Division
•
8087 Co Processor( FPU)
•
8087 Co Processor( FPU) features:
•
8087 Co Processor( FPU) : Its own instruction set