Floating point decimal representation (for numbers):
-314.159 = -314.159 × 100 ≡ (-314.159, 0) = -31.4159 × 101 ≡ (-31.4159, 1) = -3.14159 × 102 ≡ (-3.14159, 2) ^^^^^^^ ^^^ Mantissa Exponent |
Floating point decimal reprsentation consists of 2 decimal numbers
|
The canonical form:
|
Example:
-314.159 = -314.159 × 100 ≡ (-314.159, 0)
= -31.4159 × 101 ≡ (-31.4159, 1)
= -3.14159 × 102 ≡ (-3.14159, 2)
Canonical form: (-3.14159, 2)
|
Floating point binary representation (for numbers):
-101.01011 = -101.01011 × 100 ≡ (-101.01011, 0) = -10.101011 × 101 ≡ (-10.101011, 1) = -1.0101011 × 1010 ≡ (-1.0101011, 10) ^^^^^^^^ ^^^ Mantissa Exponent |
Floating point binary reprsentation consists of 2 binary numbers
|
The canonical form:
|
Example:
-101.01011 = -101.01011 × 100 ≡ (-101.01011, 0)
= -10.101011 × 101 ≡ (-10.101011, 1)
= -1.0101011 × 1010 ≡ (-1.0101011, 10)
Canonical form: (-1.0101011, 10)
|
Notice that:
|
Examples:
1.000101 -1.101111 |
(The only exception is the value 0.0, which will be represented by a special code)
What is the IEEE 754 standard
|
Codes used for the mantissa and exponent:
Mantissa: sign-magnitude binary code Exponent: excess 127 binary code |
Storage format (uses 32 bits or 4 bytes):
SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM Bit: 01 89 31 S = sign of the mantissa (0 = pos, 1 = neg) M = mantissa without the leading 1 (23 bits) E = exponent (8 bits) |
Note: the leading 1. in the mantissa is assumed (and omitted) !!!
Suppose you are given the following IEEE 754 (single precision) representation:
|
We can find the decimal representation for this IEEE 754 code as follows:
01000000101000000000000000000000 = 0 10000001 01000000000000000000000 ^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ | exponent mantissa (with leading "1." omitted) sign (= positive mantissa) |
Demo:
|
Notice: you
write a
float number in
decimal notation in the
source program file.
The assembler translates it
into the
IEEE 754 representation
and stores
the binary representation in memory
Suppose you are given the decimal number −5.25
How to find the IEEE 754 representation:
1. Encode -5.25 into fixed point binary representation -5 --> 101 0.25 --> 0.01 -5.25(10) = -101.01(2) 2. Find the canonical form: -1.0101 exponent 10(2) 3. Code the exponent into Excess 127: 01111111 + 10 = 10000001 4. Put the different parts in their places: SEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMM 11000000101010000000000000000000 |