Skip to content

Commit

Permalink
ensure _samples is power of 2
Browse files Browse the repository at this point in the history
  • Loading branch information
xuteng0 committed Mar 11, 2024
1 parent 91ca0c4 commit bc1e5bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions MovingAverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ void MovingAverage<T, N>::set_samples(uint16_t samples) {
while (_samples >> _shift != 1) {
_shift++;
}

_samples = 1 << _shift; //ensure _samples is a power of 2

}
}

Expand Down

0 comments on commit bc1e5bf

Please sign in to comment.