|
|
(Remember that multiply/dividing by 10 with decimal number can be accomplished by shifting the decimal point one place to right/left)
Then, we can represent the number 314.159 using a pair of numbers:
|
The first number is the mantissa and the second is the exponent.
|
(Similarly, multiply/dividing by 2 with binary number can be accomplished by shifting the decimal point one place to right/left)
We can represent the number 1010.1011 using a pair of binary numbers:
|
The first number is the mantissa and the second is the exponent.
|
|
Given the following floating point representation: 01000000101000000000000000000000 = 0 10000001 01000000000000000000000 ^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ | exponent mantissa (with leading "1." omitted) sign |
Hands-on experimention: click here
S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0 1 11 12 63
How to run the program:
|
Use the Variable display window to show the content (= bit pattern) stored in the variable floatCost as binary Signed Int and as Float
Try it with different values.
This demo shows that:
|
Here is a nice webpage where you can construct floating point representations: click here
When you explore the above webpage, you must know that there are 2 things that are strange in the IEEE float representation
So if the mantissa bits in a single precision representation are 01010101010101010101010, the actual mantissa bits are 1.01010101010101010101010 (and the mantissa is between 1.0 and 2.0)
The single precision exponent uses the "excess 127" encoding which uses 01111111 to represent 0:
Bit pattern: 01111100 01111101 01111110 01111111 10000000 10000001 10000010 ----+----------+----------+----------+----------+----------+----------+- -3 -2 -1 0 1 2 3 Value represented: