Skip to content

HammingWeight

Stephen Crowley edited this page Feb 6, 2024 · 1 revision

Given an integer N, define:

  1. Shift Right:

    • $\text{ShiftRight}(N) = \text{floor}\left(\frac{N}{2}\right)$
  2. Is Odd:

    • $\text{IsOdd}(N) = N - 2 \times \text{ShiftRight}(N)$
Clone this wiki locally