Base 2 math
In base 10 math when you count from 0 to 10,
you could like this:
0
1
2
3
4
5
6
7
8
9
... But when you get to 10, instead of having a
new symbol to represent 10, you move a 1 into the 10's column
and a 0 into the 1's column.
It's very simple.
This is the meaning of base 10.
Each value place can represent 10 digits in base 10.
The value places for the base 10 numbering system are:
1's 10's 100's 1000's etc...
Notice in base 10, each column is 10 times the previous column.
each value in each column represents that many instances of that
columns place value.
50 in base 10 would break down like this:
(5 x 10) + (0 x 1)
That is, you have 5 10's and 0 1's, thus:
(5 x 10) + (0 x 1) = 50
Base 2 numbering systems work the same, except for when you carry your digit...
In base 2 numbering systems, there are only 2 numbers that can be used in your
number places: 1 and 0
To count 9 numbers you would count like this...
One 1
Ten 10
Eleven 11
One Hundred 100
One hundred One 101
One Hundred Ten 110
One Hundred Eleven 111
One Thousand 1000
One Thousand One 1001
The reason you do it like this is because any number other 1 or 0 is
invalid in base 2 numbering systems. Hence only the numbers above(one, ten, eleven, etc)
have 1's and 0's.
Yes! Those are technically the correct words to use when counting in binary!!!!!
But remember.... One Hundred in Base 2 is not the same as One Hundred in Base 10.
The names are the same, but the values they represent are different.
Now a quick note.
In a traditional Base 10 numbering system,
You would never prefix a number with a 0.
Example
0075 in base 10
would be identical to 75
The same is true for base 2.
00001001 is identical to 1001
The only difference is that the computer actually
stores the prefixed 0's.
So really, your binary to a computer numbers look like this:
One 00000001
Ten 00000010
Eleven 00000011
One Hundred 00000100
One hundred One 00000101
One Hundred Ten 00000110
One Hundred Eleven 00000111
One Thousand 00001000
One Thousand One 00001001
So here is how to Convert base 2 to base 10:
From right to left,
The value places of base 10 are as follows:
1's, 2's, 4's, 8's, 16's, 32's, 64's, 128's, etc...
So in base 10, the value places are related to each other by a factorial of 10.
Well in base 2, the value places are related to each other by a factorial of 2.
So just like in the base 10 example, we will use the factorials to calculate the value
of a base 2 number.
The base 10 value of the binary number One Thousand One, or 00001001 is calculated like this.
(128 x 0) + (64 x 0) + (32 x 0) + (16 x 0) + (8 x 1) + (4 x 0) + (2 x 0) + (1 x 1)
- simplify -
0 + 0 + 0 + 0 + 8 + 0 + 0 + 1
- simplify more -
8 + 1
- finish conversion of base 2 to base 10-
8 + 1 = 9
So the base 10 value of the base 2 number(00001001) is 9
As a side note, base 2 numbers are also referred more commonly to as Binary numbers.
It is also important to note that each 1 or 0 in a binary number is commonly referred to
as a bit.
Computers store bits in groups of 8, these groups are called bytes.
Lets see if you can convert this next binary number to base 10:
11111111
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
8 bits can can store a maximum base 10 value of 255.
An interesting thing that can be said about bytes is that
low level software breaks bytes down into two parts:
A high order nibble, and a low order nibble. A nibble is 4 bits long.
HON LON
1111 1111
The place values of a low order nibble are lower than the place
values of a high order nibble.
The place values for low order nibbles from right to left are: 1, 2, 4, 8
The place values for high order nibbles from right to left are: 16, 32, 64, 128
So as you can see, they are still part of a byte.
That's another story for another time...
To get back on topic,
The reason computers store binary numbers in groups of 8 bits is because
co-incidently, in hex(base 16), 0xFF(hex for 255) = 11111111
Also co-incidently, this is why we have nibbles.
If a byte was only 4 bits long, then the hex representation of the highest
value that a byte could store would be 0xF.
But it isn't, so don't get confused!
For fun, click the link below and take a look at images of what the electronic waveforms
for various binary numbers would look like.
There are also some conversions as well.
Binary Table