Answer the question
In order to leave comments, you need to log in
How to build a function to decode the classic Elias code if the direct encoding works correctly?
Hello everyone, Elias's classic code's direct encoding function is OK, everything works:
return (int(log(int(log(number,2)),2))*'0'+' '+str(bin(int(log(number,2))+1))[2:]+' '+str(bin(number)[3:]))
Answer the question
In order to leave comments, you need to log in
Describe in words what this encoding does, what does it write to the file?
And read this:
1) count how many zeros go at the beginning of the string.
2) This is how many bits you need to read further and translate into a decimal number system.
3) This is as many bits as you need to read further and convert to the decimal system in order to decode the number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question