I have found a few sources which have said that the number of bits in a binary number is equal to
But this doesn't seem to work for binary values less than 1. I would expect the value 0 to have zero bits. But plugging in 0 for n is not in the domain of the function. Stranger results are given by plugging in values like 0.2 which give -2 bits. This doesn't sound right. So I created this equation:
It has the same output as the previous function for all $n>=1$. It even says 0 is 0 bits, and 0.2 is 1 bit, as I would expect.
Why do people seem to like the first function more? Can someone explain why the number of bits in 0 is undefined in terms of Shannon information?
Here are a the sources I drew from:
MathWorld states the first equation is equal to the second, but ignores values less than 1. http://mathworld.wolfram.com/BitLength.html
I'm looking for a strict mathematical explanation for the number of bits in 0 in terms of information theory. The two equations above give different answers, so which is correct and why? To clarify, I don't mean the physical length of '0' or the length of the string that represents '0', but the value zero itself.
According to Mathematica,
"BitLength[n] gives the number of binary bits necessary to represent the integer n"
and executing this command,
BitLength -> 0
but even the Mathematica documentation and MathWorld fail to give a reason for this.