How can you track time in a simple embedded system, given that you need a fixed time representation in seconds and that your time between ticks is not clearly expressed in this fixed-point format? Avoiding cumulative errors in these circumstances.
This question is a reaction to this article on slashdot.
0.1 seconds cannot be clearly expressed as a fixed-point binary, just as 1/3 cannot be clearly expressed as a fixed-point decimal. Any fixed point binary representation has a slight error. For example, if there are 8 binary bits after the point (i.e., using an integer value scaled by 256), 0.1 times 256 is 25.6, which will be rounded to 25 or 26, which will lead to an error of the order of -2, 3% or + 1.6%, respectively. Adding more binary bits after the dot reduces the scale of this error, but cannot eliminate it.
When you add it again, the error gradually accumulates.
How can this be avoided?
source
share