This is a web page of David Casperson |
|
This page is under construction.
This page is a test.
A number like 13 is 1101 in binary. The sum of the binary digits is three. This is easy enough to see. Can we compute this without first converting a number from decimal to binary? Yes!
One technique is based on dividing by two and rounding down. 13 divided by two is 6.5, which rounded down is 6. Next we get 3, then 1, then 0.
We can turn this into one long substraction 13-6-3-1-0, which is 3. This is the number of ones in the binary representation of 13 (1101).
fall-2024