If a binary number is greater or equal than another one, does it have the same or more number of digits?

63 Views Asked by At

This question came up to my mind while dealing with complexity of binary operations, speciffically with multiplication.

The question. Let's say we have two binary numbers $n$ and $m$, such that $n \geqslant m.$ Can we guarantee (only with this information) that the number of digits of $n$ (say $k$) is greater or equal than the number of digits of $m$ (say $l$), i.e, can we guarantee that $k \geqslant l?$

My thoughts. This obviously should be a trivial question but I was unable to find an answer for it with a quick search on the internet. Therefore, I started thinking: Firstly, by contraposition, it suffices to show that if $l > k$, then $m > n.$ Therefore, let us fix arbitrary binary numbers $m$ and $n$ such that $l>k.$ The worst case scenario (where our thesis is most likely to fail) is if $m$ is just a sequence of zeros that ends in a $1$, i.e., if $m = 10\dots 0$ and $n$ is a sequence of ones with exactly one less digit than $m$ (here, we are just picking the smallest possible value for $m$ and the highest possible value for $n$). Therefore, transforming into decimal we can say that $(k = l-1)$

$$ m = 2^{k} \quad \text{ and } \quad n = \sum_{i=0}^{k-1} 2^i. $$

Now, it suffices to see that

$$ n = \sum_{i=0}^{k-1} 2^i = 1 + \sum_{i=1}^{k-1} 2^i = 1 + \frac{2(1-2^{k-1})}{1-2} = 1 - 2 + 2^k = 2^k - 1 < 2^k = m, $$ proving what's wanted.

Is this result true and are my thoughts behind it acceptable?