









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










10/10/
if ((A + A) - A == A) {SelfDestruct()}
10/10/
Many applications require numberswith a VERY large range.(e.g. nanoseconds to centuries)
-^
Most scientific applications need real numbers (e.g.
ππππ
We COULD use integers with a fixed “binary” point
-^
We COULD implement fractions using two integers(e.g.
Floating point is a better answer for most applications.
10/10/
Is straightforward:^ –
Multiply together the significant parts – Add the exponents – Normalize if required
-^
Examples:
1024
x^
10
3
x 0.
x^
10
64
x 10
1
42
x^
10
1
x 0.
x^
10
x^
10
x^
10
0 (Normalized)
In multiplication, howfar is the most you willever normalize?
In addition?
10/10/
IEEE single precision floating-point format
0x42280000 in hexadecimal
Exponent: Unsigned “Bias 127” 8-bit integer
E = Exponent + 127 Exponent = 10000100 (132) – 127 = 5
Significand: Unsigned fixed binary point with “hidden-one”
Significand = “1”+ 0.01010000000000000000000 = 1.
Putting it all together
N = -
S^ (1 + F ) x 2
E-
= -
0 (1.3125) x 2
5 = 42
0 (^01) 0 0 0 (^01)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(^01) 0 1 0
0
“F”
Significand (Mantissa) - 1
“E” Exponent + 127 “S”SignBit
L12 – Multiplication 7
10/10/
-^
-^
Here’s where the hidden “1” comes back to bite you
-^
Hint: Zero is small. What’s the smallest number youcan generate?
-^
E = Exponent + 127, Exponent = -127, Signficand = 1.
(1.0) x 2
= 5.87747 x 10
differently… 0 00000000 00000000000000000000000 = 0 not 1.0 x 2
1 00000000 00000000000000000000000 = -0 not -1.0 x 2
Yes, there are “2” zeros. Setting E=0 is also used to represent a few other small numbersbesides 0. In all of these numbers there is no “hidden” one assumed in F, and they are calledthe “unnormalized numbers”. WARNING: If you rely these values you are skating on thin ice!
L12 – Multiplication 8
10/10/
“Denorm
Gap”
0
2
2
2
-bias
1-bias
2-bias
normal numbers with hidden bit
The gap between 0 and the next representable normalized number is much larger
than the gaps between nearby representable numbers. IEEE standard uses denormalized numbers to fill in the gap, making the
distances between numbers near 0 more alike. 0
2
2
2
-bias
1-bias
2-bias
p bits ofprecision
p- bits ofprecisionDenormalized numbers have a hidden “0” and a fixed exponent of -126NOTE: Zero is represented using 0 for the exponent and 0 for the mantissa.Either, +0 or -0 can be represented, based on the sign bit.
X = (-1)
2
(0.F)
S^
10/10/
It is CRUCIAL for computer scientists to know that
Floating Point arithmetic is NOT the same arithmeticyou learned in grade school! 1.0 is NOT EQUAL to 10*0.1 (Why?)
ex. 1.0 * 10.0 == 10.
but,
0.1 decimal == 1/16 + 1/32 + 1/256 + 1/512 + 1/4096 + … ==
0.0 0011 0011 0011 0011 0011 … Consider, in decimal 1/3 is a repeating fraction 0.333333…If you quit at some fixed number of digits, then 3 * 1/3 != 1
10/10/
Floating point is an approximation of “Real Numbers”;it even breaks basic LAWS of math^ Floating Point arithmetic IS NOT, in general, associative
x + (y + z) is not necessarily equal to (x + y) + z
Thus, the order of calculations matters, and should be considered
-^
Arithmetic is approximate whereas integer arithmetic isexact. Operations may not result in any visible change
(x + 1.0) MAY == x
Floating-point is often
overused
by programmers, since
the “finiteness” of the representation less apparent
-^
Programmers who assume that floating point numbersare real numbers, do so at their peril
10/10/
L12 – Multiplication 14
10/10/
E^
F^
S^
E^
F
24 by 24 round
SmallADDER
Mux (Shift Right by 1)
Control
Subtract 127^ Subtract 1
S^
E^
F
Step 1:^ Multiply significandsAdd exponentsE
= ER
-127 2
Exponent
Exponent
127 1
Exponent
127 2
[1,2) *[1.2) = [1,4)at most we shiftright one bit, andfix exponent
Surprisingly, FPmultiplication issimpler than FPaddition
10/10/
Computer arithmetic is constrained by limited precisionBit patterns have no inherent meaning but standards do
exist^ two’s complementIEEE 754 floating point Computer instructions determine “meaning” of the bit
patterns Performance and accuracy are important so there are many
complexities in real machines (i.e., algorithms andimplementation). Numerical computing employs methods that differ from
those of the math you learned in grade school.