This tip has been extracted from the full Scaled Integers article.
If you need variables to hold a very large range of values or hold a small range of fractional values, then your project might benefit from using smaller integer types to store scaled integer values. This technique reduces data memory usage and can drastically increase code execution speed.
Scaled integers hold regular integer values, but the implied scaling factor indicates how the scaled integer value is to be interpreted. Integer values can be scaled up or down to suit your requirements. Scaled-up integers tradeoff precision for range (e.g., scaling by a factor of four: 0, 4, 8, 12, etc.); scaled-down integers trade-off range for precision (e.g., scaling by a factor of two: 0, 0.5, 1, 1.5, etc.).
There is typically some computational overhead when working with scaled integers, but unlike floating-point values, there is no separate exponent to deal with, so this overhead is much lower.