/* Adds a new value to the sma_f_t instances.  */
void sma_f_add(sma_f_t *sma, float x)
/* Adds a new value to the sma_f_t instances.  */
void sma_f_add(sma_f_t *sma, float x)
{
  float *pSource = sma->buffer + (sma->k % sma->size);
  sma->total -= *pSource;
  *pSource = x;
  sma->total += x;
  sma->k++;
  if (sma->k < sma->size)
    return;
  double tmp_total = sma->total;
  uint64_t *ptr = (uint64_t *)(&tmp_total);
  *ptr -= ((uint64_t)(sma->exponent)) << 52;
  sma->avg = (float)(tmp_total);
}