Binary for Dummies

Baorite

BANNED
"There are 10 kinds of people in this world, those who understand binary, and those who don't"
So I spent my day yesterday browsing the internet as usual, and somehow learned binary while I was doing that. As you probably know, binary is just a series of 1s and 0s to make up a code, and it was used way back in the early days of computers (about 10-20 years). To the untrained eye, it looks like something from the matrix, but if you know how to read it, it won't do anything because nobody actually uses binary anymore, but it's still cool.

So, you read binary from right to left if you are decoding it, but left to right if you are trying to get binary.
Also, when reading right to left remember that the numbers double each time:
Code:
00000000 would equal 128,64,32,16,8,4,2,1
because it doubles each time from the right to the left.
Now those were just 0s right? Well with 1s it's the same thing, however you have to add the values of numbers that have 1, and not the numbers that have 0, so if you have "10101" this is how you would solve it.
Code:
10101  1  0  1  0  1
      16  8  4  2  1
Now, I put the value if each number. Whether it is a one or
a zero, this part does not change. 000000 would have the same value
and 111111 would have the same values.
Now, what you have to do is this:
Find each spot that has a 1 and add those values together, so:
1+4+16, Because those are the spots with 1s.

 
That gives you 21, so 21 in binary is 10101.
Now what about letters? Letters are a bit different. First you have to know how to put a number into binary, so the opposite of what we did. First write out this key, because this is the key that is used to decipher letters in binary (note: letters in binary are 8 numbers long, like this :00110001)
128 64 32 16 8 4 2 1
This is what you will use. Now letters have values for binary. 65-90 are capital letters that correspond to their letters in a numerical way (65-A 66-B 67-C, so on). 97-122 are lowercase, and work the same way (97-a,98-b,99-c, so on) I'll attach a file with this key. Now, to get a letter into binary this is what you must do, take that letter, and in this case we will use capital C, which has a value of 67. Now, take the key again 128 64 32 16 8 4 2 1
and see, Does 128 go into 67? No, so you write down 0 and go on. Does 64? Yes, so you write down 1 and subtract 64 from 67. You end up with 3. Does 32 go into 3? No, write down 0 and go on. 16? No, 0, go on. 8? No, 0, go on. 4? No, 0, go on. 2? Yes, 1, subtract 2 from 3, and you get 1. Does 1 go into 1? Yes, so you write down 0, subtract 1 from 1, and you are done. So you end up with this:
128 64 32 16 8 4 2 1
0 1 0 0 0 0 1 1. Now you put them together, and you get 01000011. Captial C in binary is 01000011. Let's try one with lower case o, which is 111.
128 64 32 16 8 4 2 1
128 --> 111? 0
64 ---> 111? 1, 111-64 = 47
32 ---> 47? 1, 47 - 32 = 15
16 ---> 15? 0
8 ---> 15? 1, 15-8 = 7
4 ---> 7? 1, 7-4=3
2 ---> 3? 1, 3-2= 1
1--->1? 1, 1-1=0
And you're done! Remember, 1 means yes, 0 means no. So in the end, you get:
01101111
If you have any questions, like if I didn't explain something well enough, feel free to ask. Also I've included the key for letters.
So the key things: 1 is yes, 0 is no, use the key 128 64 32 16 8 4 2 1

Edit: Here is punctuation
 

Attachments

  • Binary letters.txt
    329 bytes · Views: 0

zackychuu

TD Admin / Wanker
I learned a way to convert IP addresses into Binary and vice versa quite a while back
Same thing for Mac Addresses
All in my head and on paper, I was quite good at it

I forgot it now but it's easily re-learned looking at my notes from the course I took.
 

Baorite

BANNED
I learned a way to convert IP addresses into Binary and vice versa quite a while back
Same thing for Mac Addresses
All in my head and on paper, I was quite good at it

I forgot it now but it's easily re-learned looking at my notes from the course I took.
So 127.0.0.1 would be 00110001 00110010 00110111 00101110 00110000 00101110 00110000 00101110 00110001 correct?
 

copper

TD Admin
There's nothing special about binary as a number system. "Binary" just means that each digit can have two values (0,1), while "decimal" (the system you're used to using) has 10 values per digit (0,1,2,3,4,5,6,7,8,9). These number systems work the same, as does octal (eight values per digit) and hexadecimal (16 values per digit). In any of these systems, each digit from right to left has an increasing power of the base.

Notation: ^ mean "raised to the power", e.g., 2^10 is "2 raised to the 10th power" (1,024)

Numbers written in any base are interpreted as follows:
Code:
(vn * b^n) + ... + (v2 * b^2) + (v1 * b^1) + (v0 * b^0)

This may look confusing, but a concrete example will help. Let's take the number 4,096. Interpreted as a decimal number this is:
Code:
  (4 * 10^3)  + (0 * 10^2) + (9 * 10^1) + (6 * 10^0)
= (4 * 1,000) + (0 * 100)  + (9 * 10)  + (6 * 1)
= 4,000      + 0          + 90        + 6
= 4,096
Binary is similar, except that the base is 2 instead of 10 (so you can't have anything but 0's and 1's for the values of binary digits). Let's take the binary number 1010.
Code:
  (1 * 2^3)  + (0 * 2^2) + (1 * 2^1) + (0 * 2^0)
= (1 * 8)    + (0 * 4)  + (1 * 2)  + (0 * 1)
= 8          + 0        + 2        + 0
= 10 (this is a decimal 10, not binary)
To take this further and use hexadecimal, the base is 16 and the values for hexadecimal are (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). FYI, hex numbers are prefixed with "0x" for clarity. Let's take the hex number 0xA41F.
Code:
  (A * 16^3)  + (4 * 16^2) + (1 * 16^1) + (F * 16^0)
= (10 * 4,096) + (4 * 256)  + (1 * 16)  + (15 * 1)
= 40,960      + 1,024      + 16        + 15
= 42,015

Binary is still used by all computer systems because it's the only way software and hardware can interface; your computer hardware represents 0 as a low-voltage signal and 1 as a high-voltage signal. Binary is not a particularly useful thing to know, however, because the software development process long ago abstracted out the use of binary into higher level language structures. Assembly language is one level of abstraction above binary (assembly instructions are interpreted by the computer as a number and the hardware can only understand binary). C/C++ (when compiled natively) is another level of abstraction on assembly (C++ instructions become one or more assembly instructions once compiled). Virtual machine languages (like Java, C#, etc.) are yet another level of abstraction because they are architecture-independent (there's a lot more to say about this, but I won't get into it). So, saying that binary isn't used any more is only true in the sense that you can write software your entire life without learning it, but your computer still uses it millions of times per second.
 

copper

TD Admin
tumblr_meydnuaFSK1qb9fuc.gif
 

$alvador

TD Member
good post copper, you shiny fucking metal, you. the good thing about binary is it's easy to convert into octal or hex. let's say you have 10111111011. It's helps to look at that as 010 111 111 011 if you're converting to octal, and 0101 1111 1011 when converting to hex.

1, 2, 4, and 8 are the key numbers to remember for the conversion. on top of each group you can list those numbers from right to left (obviously the octal groups only go up to 4 since there are three numbers per group) and each 1 indicates that you add the number above to the group's total and each 0 indicates you do not add the number.

So, 010 111 111 011 becomes 2773 in octal, and in hex you switch over to the groups of four and get 5FB. Because of the 8 added to the group the maximum value you can get is 15. In hex, it goes 0-9 then any number beyond that is by the alphabet (i.e. A is 9, F is 15).

*nix filesystem permissions go by octal (i.e. chmod xxx) but i'm too lazy to be getting into that so just read http://en.wikipedia.org/wiki/Filesystem_permissions if you have any fucks to provide
 
Top