I understand that it is efficient to use the shift operator
But I still do not get it, so I post a question.
I do not know how the numbers were determined by some method.
why it use 15 and 4
I believe somebody will explain it easily

ksghj2000:
I do not know how the numbers were determined by some method.
why it use 15 and 4
I believe somebody will explain it easily

jremington:
This line:

*p += ((((long) x << 15) - *p) >> 4);

is equivalent to

y = y + ( x*2^{15} - y)/2^{4}

The 2^{15} is a scale factor for a fixed-point arithmetic representation of the data. This allows the calculations to retain significance smaller than 1 bit of the ADC. As an example (B100000000000 + B000000000000) >> 1 = B10000000000 in this scheme is (1 + 0)/2 = 0.5. Fixed point arithmetic is generally much faster than floating point arithmetic on processors (like most Arduino) that don’t have hardware floating point capability.

The 1/2^{4} = 1/16 is the “alpha” value as per the discrete IIR discussion in the low pass filter article linked in post #1. The filter cutoff frequency can be calculated knowing “alpha” and the sample interval as per that article.

MrMark:
The filter cutoff frequency can be calculated knowing “alpha” and the sample interval as per that article.

The cut-off frequency f_{c} on that Wikipedia page is the analog cut-off frequency.
The digital normalized cut-off frequency of the exponential moving average filter is given by arccos((α² + 2α -2) / (2α - 2)). See this link: