ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Вторник
9 июля
270720 Топик полностью
++ (08.09.2011 08:53, просмотров: 238) ответил Т.Достоевский на Камрады! кто то на электрониксе привёл изящный способ усреднения, суть примерно такова.
Это арифметика с фиксированной точкой(fixed point math)для случая, если скользящее среднее по 256 значениям (деление на 256) (частный члучай): http://en.wikipedia.org/wiki/Q_%28number_format%29
x= sum(x0 .. x255)>> 256 // multiply fixed point number x with y, both are 8.8 format // we want the result to be of 8.8 format too, so we need to shift right by 8 r = (x * y) >> 8 // second example: shifts and then divides // this trick keeps the same format in the result as x or y // of course x and y are in 8.8 format in this example // so the result will be in 8.8 format too // r = (x << 8) / y
++