Until you do an operation that exceeds the range or do a divide that requires fractions which have to be truncated. What is 2,000,000 divided by 3,000,000 in fixed point? Zero. Oh, adjust the radix point in your head and its... 0.666,667, but now we have to track the moved radix point outside the real time calculation. Even then the same point in the calculations might produce 0.000,007 and we have lost significant resolution.
Ok. I'll try to explain. Math is done with values. What we discussing are different presentations of the same value. It's all binary, but I use decimals for clarity.
Say, I have 20 dollars.
Floating point: 2.0E+1
Fixed point: 20.00
For scaled integers, I shift the position of the decimal point to the right, by two. Another way, I measure in cents, not dollars:
Scaled integers: 2000
Same thing for 0.01 dollars
Floating point: 1.0E-2
Fixed point: 0.01
Scaled integers: 1
Let's now do some math.
Addition:Floating point: 2.0E+1 + 1.0E-2 = 2000.0E-2 + 1.0E-2 = 2001.0E-2 = 2.001E+1
Fixed point: 20.00 + 0.01 = 20.01
Scaled integers: 2000 + 1 = 2001
Note how floating pint requires two extra step - a shift to align mantissas and normalization at the end
Multiplication:I buy something for 205.40 cents and I need to pay 5.0% tax on it. How much is that?
Presentation of the amount:
Floating point: 2.054E+2
Fixed point: 205.40
Scaled integers: 20540
Presentation of the tax rate:
Floating point: 5.0E-2
Fixed point: 0.05
Scaled integers: 50 - I have chosen to shift right by 3 decimal points - one unit is 0.1%
Multiplication proceeds as follows
Floating point: 2.054E+2 x 5.0E-2 = (2.054*5.0)E(+2-2) = 10.27E0 = 1.027E+1
Fixed point: 205.40 x 0.05 = 10.27
Scaled integers: 20540 x 50 >>> 3 = 1027000 >>> 3 = 1027
Here ">>> 3" means shift right by 3 decimal digits.
Note that floating point multiplication is easy, but there's still an overhead - normalization at the end.
Scaled integers require a shift. It is decimal in the example, but it is binary in hardware. The amount of the shift is the same every time. Thus, in FPGA, it's nothing more than using a different set of wires - no overhead.
Division:I buy something for 205.40 cents and I need to pay 10.27 in taxes. What is the tax rate?
Floating point: 1.027E+1 / 2.054E+2 = (1.027 / 2.054)E(+1-2) = 0.5E-2 = 5.0E-1
Fixed point: 10.27/205.40 = 0.05 (5%)
Scaled integers: 1027 <<< 3 / 20540 = 1027000 / 20540 = 50
Here "<<< 3" means shift left by 3 decimal digits.
Of course, here everything is dominated by the division which will take long time. Otherwise, it's the same as multiplication - normalization overhead for floats, no overhead for scaled integers.
In short - you can do any math with scaled integers and it takes less operations than with floats, especially in FPGA.
Dynamic range:If you have numbers which differs in magnitude, you need very long integers to represent. For example, us national debt is
Floating point: 2.785208840732531E+13
Fixed point: 27852088407325.31
Scaled integers: 2785208840732531 (not really that big - only 52 bits)
If we want to deal with smaller numbers, we can use floats and chop of precision. Say, we chop it to 6 digits after decimal point:
Floating point: 2.785209E+13
Fixed point: 27852088407325.31
Scaled integers: 2785208840732531
Now we can get away with smaller numbers (for example 32-bit floats instead of 52-bit integers), but we did this by deliberately removing resolution, so the resolution will be less (not more). Floating point numbers is an approximation.
This can lead to troubles with calculations. Say, we record the debt 10 minutes later:
Floating point: 2.785213E+13
Fixed point: 27852126073450.61
Scaled integers: 2785212607345061
How much money was borrowed during these 10 minutes:
Floating point: 2.785213E+13 - 2.785209E+13 = 4.000000E+7
Fixed point: 27852126073450.61 - 27852088407325.31 = 37666125.30
Scaled integers: 2785212607345061 - 2785208840732531 = 3766612530
See what happens. Most of the digits produced by floating point calculation are totally bogus. If you just apply floating point calculations without thinking of precision, the result may be less accurate than you think, if not outright wrong.