On Mon, 2023-04-24 at 21:04 +0000, Benjamin Beichler wrote: > The uninitialized state 0 involves the danger of reaching that state in > normal operation. Since the weight_rcp value needs to be bigger than one > (otherwise no averaging takes place), the final shifting in add ensures, > that the internal state never reach ULONG_MAX. Therefore use this value > to signal, that the ewma has no initial value. > > The add function needs to check, that val is not to big, otherwise the new > value can overflow the internal state, which results in unexpected outputs. This seems nice to me, FWIW. > Move the compile time checks into a separate macro, as they are used > multiple times and noise up the functions. Why do we even have those multiple times? Should be enough to have them once, since we always compile the static inline functions? johannes