[chbot] Filter

Volker Kuhlmann list57 at top.geek.nz
Thu Oct 18 00:46:44 BST 2018


> filt_sum = filt_sum - filt_sum / 100 + raw_value;
> filt_value = filt_sum / 100;
> 
> The second line only needs to be evaluated when you actually need to use
> the result.

Why is that an evaluation improvement?
It's the same as

filt_value = filt_sum / 100;
filt_sum = filt_sum - filt_value + raw_value;

where you can read filt_value for the filter result any time. It has the
same number of expression statements but adds one store to filt_value
per step. That's very cheap compared with a division.

Volker

-- 
Volker Kuhlmann
http://volker.top.geek.nz/	Please do not CC list postings to me.



More information about the Chchrobotics mailing list