Sunday 22 January 2012

The Math in Binary Codes

So, if you didn't already know binary code is a code consist of the two digits 1 and 0. Binary code are described as a switch of off and on. Binary code is mainly used in computers, since its easy for computers to use number instead of letters. There are many ways to convert binary code to letter/ symbols, but I'll only focus on binary codes that are consist of 8 digits. I'll show how to convert binary code by yourself using math on the 8 digits code and the alt codes or the ASCII chart (basically the same thing), I think.


For example, I'll use this code "01100001" which is for the letter "a".


First, you have to know that each digit of a binary number is based on 2 to the power of x.


                                                                      0     1    1    0   0  0  0  1
so start from the right to the left it would be 128  64 32  16  8  4  2  1
you get this by 
2 to the power of 0 = 1 (2^0)
2 to the power of 1 = 2 (2^1)
2 to the power of 2 = 4 (2^2) or (2*2)
2 to the power of 3 = 8 (2^3) or (2*2*2)
2 to the power of 4 = 16 (2^4) or (etc.)
2 to the power of 5 = 32 (2^5)
2 to the power of 6 = 64 (2^6)
2 to the power of 7 = 128 (2^7)



for every place that 1 you add the number that represent 1.
for this example the one is at are at 64, 32, and 1.


which means you do this: 64+32+1=97
and this is where the alt codes/ ASCCII chart comes in. Holding alt and hit the number code 97 the letter will be "a" (note this may be different depending on the keyboard you have). And if you have the ASCCII chart with you, the number 97 is still the letter "a".

6 comments:

  1. Woah! This is so confusing! How did you manage to learn all this? I'm clueless.

    ReplyDelete
    Replies
    1. It's better to just focus on:
      0 1 1 0 0 0 0 1
      128 64 32 16 8 4 2 1

      you just add the numbers where there is a 1. and with the total you use the alt codes.

      Delete
  2. I always wondered the logic of binary code. Still bit confused though :S

    ReplyDelete
  3. I did not know that that was where the alt codes came from - they are the decimal equivalents of the binary numbers formed by their ASCII codes! So if a symbol, say square root, has an alt code of 251, that means that in binary it would be......11111011?...checking to see if those powers of 2 add up to 251......128 + 64 + 32 + 16 + 8 + 0 + 2 + 1...... = 251! aaaaaaaaah it works!

    ReplyDelete
  4. .... Say whaaaaa! This is so confusing. How and where did you learn this? So cool

    ReplyDelete
  5. This blog, like blogs of many of your classmates, shows me how you relate math to your own interests. What are your career plans? Something technology related, I am guessing. Nice post, Cayce!

    ReplyDelete