Subsection 13.4.4 Scaling One Integer Range onto Another
Two C facts matter whenever one integer range is scaled onto another. First,
/ on two integers discards the remainder, so a scale factor smaller than 1 written as a division comes out as 0; multiply before you divide. Second, the product is computed in int, which is 32 bits on the STM32C031C6, so a 12-bit reading times a range of a few hundred fits easily (4095 Ă— 200 = 819,000 is more than a 16-bit variable holds, and fits in an int with room to spare). And if the divisor is the number of possible readings, 4096, rather than the largest reading, 4095, the top of the output range is one step short, which is usually fine and is worth knowing.
