Floating Point numbers |
Floating point numbers allow us to store decimal values. Consider the number 2.5. This will be stored as "10.1". How was this value calculated? Look at the table below -
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | . | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
So how could 6.75 be stored?
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | . | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
so it is 4 + 2 + 1/2 + 1/4 = 6.75
To convert binary to denary you need to work out both sides of the decimal point. For example
1101.1101
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 |
0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | . | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
8 + 4 + 1 = 13
1/2 + 1/4 + 1/16 = 8/16 + 4/16 + 1/16 = 13/16
13.8125
Note - I have factored the fractions as I personally find this easier. You can just work this out on a calculator by (1/2) + (1/4) + (1/16) = 0.8125