Average of a sensor

I don't believe it correct to do that, I believe truncation is better.

simple example, 10 measurements of an analogRead()

The integer average with truncating
{ 109 109 109 109 109 109 109 109 109 108 } = 1089/10 = 108

The integer average with rounding
{ 109 109 109 109 109 109 109 109 109 108 } = (1089+5)/10 = 109

The float average
{ 109 109 109 109 109 109 109 109 109 108 } = 1089/10 = 108.9

(for above example)
with rounding the max error = 0.5 so the average error is 0.25
with truncating the max error = 0.9 the average error is 0.45
So there is a factor 1.8 difference in the max & avg error

However I do not know the requirements of your project, so I cannot say if rounding is correct or not.

// the numerical implication of error propagation in a rolling average are a bit more complex
// but it is a faster method than taking dozens of samples (when executed in integer domain)