Closed Maumagnaguagno closed 2 years ago
@Maumagnaguagno They may give the same result, but my guess is that the one operating on even numbers works quicker.
Yes, the formula operating on even numbers is "quicker", n_quotes / 2
, than the one for odds, (n_quotes - 1) / 2
, which is one of the reasons I want to use the even formula for both evens and odds. The main reason is to simplify the code and make clearer that what is pushed to value
is the same for both cases.
Thanks!
Division by two of odd
n_quotes
(integer >= 0) does not need to decrement one to generate the same result as even numbers. Division by two already removes the least significant bit that is being subtracted: (0bxxx1 - 1) / 2 => 0bxxx0 / 2 => 0bxxx.