I have always wondered how to remember the 1 s and Os in binary.
We in the modern world use a base ten system which means that we have ten seperate digits that can be used to make any number at all; 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. However binary only has two digits; 0, and 1. This is because in electronics something can be either on or off. Nothing is ever in between those two states. Also, all computers begin to count by 0. So 0 is 0000.
1 is 0001.
(Note: the zeros in front of the 1 don’t mean anything, just like they wouldn’t when humans count.)
We dont have any more digits to go on! so like our base ten system, we add a zero to the end.
2 is 0010
3 is 0011
We can’t go on anymore, so we add a zero and start again.
4 is 0100
5 is 0101
6 is 0110
7 is 0111
Add a zero.
8 is 1000
9 is 1001
We don’t need to go any further than this, since in our world, we can make any number with the digets 0-9. However, the number 12 isnt just 0001 (one) 0010 (two) because like we usually count, 1+2 does not equal 12.
(You could write it like this:
0 0
0 0
0 1
1 0
But that looks uglier and is less efficient unless you are talking about a binary clock.)
(in case you were wondering, 12 is actually 1100, as you can figure out later.) The rule of ‘tens places’ like 10 apples (The one in ten stands for ten apples, while the zero stands for no other apples.) applys with binary too, only it goes by twos.
so here is a comparison of the Base Ten system and the Binary system
…100000 10000 1000 100 10 1
… 32 16 8 4 2 1
So as another example, to show 18 in binary, write down the binary numberline above, and look for the closest number that is lower than 18.(If a number is higher than 18, put a zero under it.) It is 16. So put a one under the 16, and subtract 16 from 18 to get two:
…512 256 128 64 32 16 8 4 2 1
0 0 0 0 0 1
Now take two, and keep going from where you left off. Put a zero under the number if it is bigger than two:
…512 256 128 64 32 16 8 4 2 1
0 0 0 0 0 1 0 0
Now we have gotten to a two, so we can put a one on it and the difference between 2 and 2 is zero, so you can just put a zero on all of the other numbers! (a.k.a. the remaining one that is dangling off the edge)
So our remaining number is 0000010010, cutting off all of the trailing zeros that don’t mean anything reads 10010. So that is 18.
To be even more efficient, you can use a hex code, which reduces these digits into much less. Raw computers cannot read hex-codes. To convert binary into a hex-code, you take our binary 18 (10010) and bring back some of the trailing zeros so that it equals a number in our binary number line (512 256 128 64 32 16 8 4 2 1) in this case, the nearest number is 8. So we add enough zeros so that there are 8 digits. making it 00010010.
Chop it up so that they are ‘nibbles’ of four digits each, and then calculate the binary digits again. Put them together and add an h on the end to represent hex. This will only work with two digit base ten numbers or more.
0001 | 0010 = 1 | 2 = 12h. So 18 is 12 hex.
Also, if you have a number higher than 10 in four binary digits, it would go alphabetically.
10 in hex is A
11 in hex is B
so on.
Notify me with a comment if you don’t get heads or tails of this.