MadSci Network: Computer Science
Query:

Re: Any algorithm for converting binary figures?

Date: Fri Oct 20 12:41:38 2000
Posted By: Xiao Chen, Staff, Academic Technology Services, ATS UCLA
Area of science: Computer Science
ID: 971571546.Cs
Message:

This particular algorithm that you are referring to is a fairly 
straightforward one. It is actually explained in the webpage that you 
mentioned. (http://www.madsci.org/posts/archives/may97/860080218.Cs.r.html)

Here is how it works. Given a binary string, you start from left to right. 
You count the number of 0's, that will be  the first digit in your new 
number and then you count the number of 1's, that is the second digit in 
your new number, then number of 0's , then number of 1's in an alternating 
manner. Keep going all the way through. This is the number (compressed 
string)  you are looking for.  You can translate any binary string into the 
compressed string  and vice versa. For example, suppose our compressed 
string is 12345. Then the binary string corresponding to it is
011000111100000. Conversely, if you have a binary string such as
00111100110101100101. The compressed number corresponding to it will be
242211122111. 

Notice here we are just talking about a general binary string. In computer 
science, binary strings don't appear as an arbitrary string. The simplest 
case is that they may come as a group of bytes (bytes could consist of 8 
bits) and you want to keep them that way. Then we may want to apply the 
algorithm within each byte.  

I hope this will help a little bit. 

Good luck.



Current Queue | Current Queue for Computer Science | Computer Science archives

Try the links in the MadSci Library for more information on Computer Science.



MadSci Home | Information | Search | Random Knowledge Generator | MadSci Archives | Mad Library | MAD Labs | MAD FAQs | Ask a ? | Join Us! | Help Support MadSci


MadSci Network, webadmin@www.madsci.org
© 1995-2000. All rights reserved.