3 ms·
It seems to be a complicated way to explain that, if you need decimal values, you can just multiply then by a power of two internally. e.g. if you just need a r
by astrobe_ 4y ago
It seems to be a complicated way to explain that, if you need decimal values, you can just multiply then by a power of two internally. e.g. if you just need a resolution of 1/256 (a case that comes to mind are measures coming from a analog-to-digital converter), you just multiply everything by 256 and do your arithmetic as usual. Or actually you don't have to do anything except remember to scale your constants the same way and do the conversion for I/Os where needed. Might be wise to protect those values with a dedicated type to prevent mistakes.
The "saturation" thing in the article is a joke; no way you can get correct results at the end if you cap the result of computations on overflow. That's slightly better than letting the overflow happen, but the right thing to do is to throw an error, not silently min/max the result.
- adhesive_wombat 4y agoSaturation is a real thing: lots of DSPs use Q-format fixed-point integer maths with saturation. It's not designed to not have errors, it's a way to detect overflows without floating point capability. You can't always just throw an error in some hard real time systems (though you obviously need to take care of saturated results "carefully", which depends on what you're up to).