I don't know the name of this encoding, but notice that with $k$ digits you'll be able to encode exactly $2^k$ numbers. In particular, those starting from:
$
\sum_{i=1}^{k-1} 2^i =2^{k}-2.
$
It follows that, given an integer $n$, the number of digits of the encoding can be found as the largest value of $k$ such that $2^k \le n+2$, i.e., $k=\lfloor \log_2 (n+2) \rfloor$. Notice that $k$ is exactly one less than the number of digits needed to write $n+2$ in binary, so you can find it in time $O(\log n)$.
Then, you can also write down the actual digits in time $O(k)=O(\log n)$ by looking at the binary representation of $n-(2^k-2) = n-2^k+2$.
As an example, the encoding of $42$ consists of $k=\lfloor \log_2 (44) \rfloor = 5$ digits (since $2^5=32$ and $2^6=64$). These digits are $01100$ (notice the leading $0$) since $(42-32+2)_{10} = (12)_{10} = (1100)_2$.
To decode a number, you can do the reverse: count the number $k$ of digits in the encoded version, then add together $2^{k}-2$ and the number whose binary representation corresponds to the given digits. This also requires $O(k)=O(\log n)$ time.
For example, the encoded number $01100$ has $5$ digits, so the represented integer is $(2^5 -2)_{10} + (01100)_2 = (30 + 12 )_{10} =(42)_{10}$.
Decode(11)
equals5
, not4
. $\endgroup$