Documente Academic
Documente Profesional
Documente Cultură
Fractional numbers
Floating point scientific notation
Floating Point Representation
Floating point in binary
IEEE Floating Point Standard
DCS111 Computer Architecture
Behaviour of Floating Point Numbers
Recap: fractions
Decimal 5.6710 is
5 x 100 plus
Fractional Numbers 6 x 10-1 plus
7 x 10–2
… not whole numbers
Binary 11.0112 is
1 x 21 plus
1 x 20 plus
0 x 2-1 plus Quiz: what is
1 x 2–2 plus 11.0112 in decimal?
1 x 2–3
Third is 0.33333…
Not all numbers can be represented exactly
(with limited digits)
1
Problem Solution 1 – Fixed Point
How to hold fractions in computers?
Divide bits between whole and fractional parts
0 0 1 1 1 1 0 1
2
Normalisation
Advantage of Scientific Notation
}
Large range
0.002 x 100
Constant proportional accuracy (… with
0.2 x 10-2
exceptions)
2.0 x 10-3 all the same value
20 x 10-4
Quiz:
• Effect of negative mantissa?
• Effect of negative exponent?
First digit
always 1
3
Representation (32 bits) Negative exponents - how?
Sign bit S – 1 bit
Aim: ALU (Arithmetic Logic Unit) can reuse
Exponent E – 8 bits integer machinery
Mantissa M – 23 bits BUT
Eg, comparison with zero: x > 0
Easy because of sign bit
Floating point numbers can be easily classified as
negative or positive
exponent fraction (mantissa)
sign
Comparison of two floating point numbers x<y
not so straightforward...
(-1)S x 1.M x 2E choose exponent representation to help
First digit always 1, so
not included
0 00000000 000 …
Bad Design
4
IEEE 754-1985
What is IEEE?
Standard important for
IEEE Standard exchange of data
portability of code
5
Quiz IEEE FP Extra’s
What are
Zero
Both E and M = zero
0 10000001 111000 ... 000 Can be positive or negative
smallest smallest positive (>0) largest smallest smallest positive (>0) largest
largest negative largest negative
Quiz: find the largest and smallest FP in IEEE
Largest/smallest +/- (2 – 223) x 2127 ≈ 1038
32-bit
Near zero (normalised numbers)
+/- 1.0 x 2-126
6
How do they behave? Summary
If x, y are positive is:
FP scientific notation
x+y>x ?
Normalised representation in binary
If x and y are different can:
Bias to represent -ve to +ve range in exponent
x–y=0?
Notice how a 32-bit binary number can
Do these rules hold: represent many different entities in memory
(x + y) + z = x + (y + z) ?
Underflow as well as overflow
(x * y) * z = x * (y * z) ?
x * (y + z) = x*y + x*z ?