'Leetcode 191: mod 10 versus mod 2

I am working through Leetcode's problem 191: Number of 1 Bits, and am confused as to a certain aspect of the solution. Here is the question:

Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

And here is my (correct) solution:

func hammingWeight(num uint32) int {
    c := 0
    for num > 0{
        if num%2==1{
            c++
        }
        num/=2
    }
    return c
}

My question is twofold:

  1. Does the program read input such as 0001101 as a binary number, and if so, why? I assumed that for a uint32 parameter, it would read it in decimal by default.

  2. When shifting over to the right, why do we use /2 instead of /10?

I am still trying to wrap my head around the basic bit manipulation stuff, so this is still confusing me. If you take 0001101 and int divide it by 2, you would get 550, not 110. But if you take the same number and int divide it by 10, you would get 110. Why is /2 correct?

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source