3 ms·
The right way to do this is: scaled = raw * mult >> shift; Calculate mult and shift based on the timer frequency. The multiplication likely needs to be do
by amluto 8y ago
The right way to do this is:
scaled = raw * mult >> shift;
Calculate mult and shift based on the timer frequency. The multiplication likely needs to be done with a 96 or 128 bit output. If shift is forced to be >= 64 (on a 64-bit machine), then the resulting assembly code is short and fast.