Hey guys what would be the easiest way of converting binary to ascii?
Printable View
Hey guys what would be the easiest way of converting binary to ascii?
Sorry could someone explain bit more about bit shifting as i dont fully understanf this
Let's take the binary number 11001101 (that's 203 in decimal). If you bitshift left one (that is, have Number << 1), the bits become 10011010. Here's a pictorical view with alignments:
The area between the | and | indicates what is being used. Those outside it are discarded (or converted to zeros). That's the general idea. This demonstrates 8-bit, but it works the same no matter how many bits you use, even 1,048,576 (provided there was a data type that big).Code:00|11001101|00 // original
01|10011010|00 // number << 1
11|00110100|00 // number << 2
00|01100110|10 // number >> 1
00|00110011|01 // number >> 2
I'm pretty sure that there are some special indications for C (such as getting printf to print the binary representation of the decimal number 168). I, unfortunately, don't know it. There's one for octal and hexadecimal as well.
What don't you understand about it? It's pretty straight forward... << shifts numbers left, >> shifts numbers right.
But that has nothing to do with binary to ASCII conversion. There's no conversion that needs to take place at all. The ASCII table is just an ordered group of number values. You can represent a given character in a number of ways, including binary.
Maybe this will help: http://www.catb.org/~esr/faqs/smart-questions.html