I have been trying for the last three days to understand the exact differences between floating and fixed point representations. I am confused reading the material and I'm unable to decide what is right and what is wrong.
One of the problems is with the meaning of few technical terms like 'precision', 'mantissa', 'denormalised', 'underflows' etcetera.
Can anyone give the differences with examples?
The points I have been able to find out until now (and able to understand clearly) are as follows :-
Floating point -
1. Advantage Provides a very large range
2. Disadvantage Rounds off large numbers
Fixed point -
1. Advantage Numbers are represented exactly (Used when 'money' is involved)
2. Disadvantage Provide a very limited range
But I know there are a lot more differences (Advantages and disadvantages mainly). Can anyone list them out with explanations?
The technalities behind floating point take a lot of time to get used to. I will not go into detail here.
Simply stated, floating points achieve a high domain (from very small numbers close to zero to very high numbers, sometimes even higher than the number of atoms in the universe). Floating points achieve this by keeping the relative error constant. I.e. the number will start to be rounded after an fixed number of decimals (this is a simplification, but helps to understand the principle). This is very similar to the concept of "significant figures" from most natural sciences. However this means that floating point numbers are always somehow rounded. If you add a very small number to a very big number, the small number will just be truncated and the big number will stay. This happens when the small number is below the the threshold. If you add many numbers it might sometimes be necessary to sort them first and adding the small ones before the big ones. There is also the concept of numeric stability to consider, i.e. how an algorithm will drift of from the correct result due to the rounding.
Fixed point representation on the other hand will always have the same absolute error. If you store currency with 4 decimal places, you know your data will be off by a maximum of .00005 cent. If you add your data however, this error again might accumulate, but the rules for this are a lot different from the rules for floating points.
Unless you are duing heavy duty numeric work, these problems probably should not be considered. Most of the times floating point numbers and fixed point numbers work just fine, when good care is taken (i.e. never use ==
on floating point numbers or fixed point numbers. The correct way to compare them however is differnt for both). Also AFAIK floats are used more often in scientific work, because most often the scientists will have training in numerics, know how to deal with rounding and are only interested in relatively exact results. Fixed points are used in finances, where each rounding has to be accounted and stored somewhere (often the banks will just keep the rounded half microcents), so you have to have a very good controll of the absolute error to be later able to account for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With