*moves your contents into %rax*

So You Think You Can Think You Can Translate Binary

good news. its simple! well, assuming your binary translates into a more or less normal string. what you will need:

the basics: bases

let's start with the basics. numbers we use are normally in base 10; we have digits ten digits (0 through 9) and if we add 1 to 9, we "roll over" and end up with 10. we can think of 10 as "one ten" plus "zero ones," just like how we can think of 36 as "three tens" plus "six ones" or 248 as "two hundreds" plus "four tens" plus "eight ones."

binary numbers, instead, are in base 2! we have two digits, 0 and 1, and when we add 1 to 1 we have to "roll over" and end up with 10... except in binary, "10" is two! it's "one two" plus "zero ones." as another example, 1110 is "one eight" plus "one four" plus "one two" plus "zero ones," which adds up to thirteen.

the third base we'll need to know about is hexadecimal--base 16! here, our digits are 0 through 9, then we have A, B, C, D, E, and F; A is 10, B is 11, etc.

the basics: characters

now let's talk about characters! a single character is represented by a string of 8 bits (those 1s and 0s); in other words, each character can be represented by a binary number that's 8 digits long.

ok, so that's the bases. now what?

ok! now, we can actually get into translating. for this turotial, let's use a simple string: 010010000100010101011001.

step one: let's break it into chunks of 8 bits! this is like separating each character, in a sense, and makes it easier to work with. we end up with 01001000 01000101 01011001. since we have 3 chunks of 8 bits, we know our ending string will only be 3 characters long!

step two: we're going to break our number up further! for each 8-bit sequence, break it up into chunks of four, like so: 0100 1000 0100 0101 0101 1001

now is where the fun part begins! as said before, hexadecimal is base 16, while binary is base 2. because 16 is the same as 2*2*2*2, any group of 4 bits--that is, any 4-digit binary number--translates to a single hex digit!

so... this means that in order to translate from binary to hex, we only need to know how to read four-digit binary numbers! this is a bit daunting at first, but once you've done it a few times it gets a lot easier.

it mostly comes down to remembering which place represents what. the leftmost place in a four-digit binary number represents eight; the second-leftmost place represents four; the second-rightmost place represents two; and the rightmost place represents one.

so, we can think of 1001 as 8 + 0 + 0 + 1 = 9, or 0001 as 0 + 0 + 0 + 1 = 1, or 0111 as 0 + 4 + 2 + 1 = 7 ... etc. so! the gist of it is, once you've broken up your binary number into groups of 8 (and then groups of 4), all you have to do is translate each group of four to its hex digit equivalent.

remember that since hex is base 16, it uses letters to represent what would be 10 through 15 in decimal. so, for example, 1111 = 8 + 4 + 2 + 1 = 15, which is F in hex. so let's do this with our number!

0100 1000 0100 0101 0101 1001

4 8 4 5 5 9

now, once you have each individual group of 4 digits translated, you just stick the two hex digits together--from the groups of four that form each full eight-digit number--to get your hex number!

0100 1000 0100 0101 0101 1001

4 8 4 5 5 9

48 45 59

and now that you have the hex numbers!! you just have to go over to the handy ascii table you pulled up earlier, and find the corresponding character for each hex number you've ended up with! doing so with the hex numbers 48, 45, 49 shows that those translate to H, E, Y... so, in the end, we find out that 010010000100010101011001 translates to "HEY"!