Binary vs Decimal
Decimal
From our previous number in the Base value Numbering System page - 384 uses three places, weighted 100, 10, and 1 - and to find the total value of a number, you multiply each digit by the weight of it's place, and add them up :
384 = 3x100 + 8x10 + 4x1 = 300 + 80 + 4 = 384
Position 0 (rightmost) : 100 = 10 to the power of 0 = 1 (anything raised to the 0 power is 1)
Position 1 : 101 = 10 to the power of 1 = 10
Position 2: 102 = 10 to the power of 2 = 10x10 = 100
Position 3: 103 = 10 to the power of 3 = 10x10x10 = 1000
Starting from the rightmost digit and moving left, you will notice the value of the digits becomes larger and larger.
For example, with 222 - the rightmost digit is a value of 2 (since it is 2 ones) then next digit to the left is a value of 20 (since it is 2 tens), and the next digit to the left is a value of 200 (since it is 2 hundreds).
Binary
The binary (Base 2) system has a similar effect.
Decimal digits have values as follows ( and allows digits from 0 to 9):
thousands hundreds tens ones, or 1000's 100's 10's 1's
so, 4372 = 4 thousands + 3 hundreds + 7 tens + 2 ones
with binary, the values are as follows ( and allows digits from 0 to 1)::
128's 64's 32's 16's 8's 4's 2's
1's
00001011 = 0 128's + 0 64's + 0 32's + 0 16's + 1 8's + 0 4's + 1 2's + 1 1's
which = 0 + 0 + 0 + 0 + 8 + 0 + 2 + 1 = 11
A number has digits, which occupy places going from right (lowest value digit) to left (highest value digit). The following table shows what each "place" is worth in binary vs. decimal systems. In binary systems, the rightmost digit (bit) is called the LSB (Least Significant Bit) and the leftmost digit is called the MSB (Most Significant Bit), die to their prospective values.
The value assigned to each place in both Decimal (Base 10) and Binary (Base 2), as well as any other numeric system (Base 4, Base 8, etc.), is found by raising the base number to the power that corresponds to the place. For example, the 4th place (and you always count from right to left) of the decimal system has a weighted value of 10 to the 4th power ( 104 ), or 1000. So, the value is equal to 1000 times whatever digit is in that place (and the range of possible digits goes from 0 to 9). The same is true for the Binary system - where the 4th place has a weighted value of 24, which is 2x2x2x2 = 16. Since there are only two binary digits, 0 or 1, this place can only have two possible values . . . 0, or 16 (1x16).
The following table shows the weighted value of each place. Then to find the total value of a number, you mutiply the digit at each place, times the weight, and then add them all up :
| Digit Place | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Decimal System Weight | 10000000's | 1000000's | 100000's | 10000's | 1000's | 100's | 10's | 1's |
| Binary System Weight | 128's | 64's | 32's | 16's | 8's | 4's | 2's | 1's |
If you ever need to figure out what a value in this table is (you certainly won't carry this table with you) - simply raise the base value to that power. For example, the value of the 5th position for binary can be easily calculated. Binary is Base 2 (Decimal is Base10), so you would raise 2 to the power of 5, which is 25 or in simple terms, multiply 2 by itself 5 times: (2x2x2x2x2 = 32).
The range of possible values that a byte can represent is from 00000000 to 11111111, which if you transpose it to decimal, goes from 0 to 255. Let's compare the previous decimal example of 384 with it's corrsponding binary representation:
|
Position of Digit |
2 |
1 |
0 |
| Number |
3 |
8 |
4 |
| Weight (10 raised to the power of the position) |
102 = 100 |
101 = 10 |
100 = 1 |
| value (number x weight) |
300 | 80 | 4 |
Decimal Base10
384 in Decimal (Base 10) = sum of all values = 300+80+4
|
Position of Digit |
8 | 7 | 6 | 5 | 4 | 3 |
2 |
1 |
0 |
| Number | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Weight (2 raised to the power of the position) |
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| value (number x weight) |
256 | 128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Binary Base2
Decimal 384 = 11000000 Binary (Base 2) = sum of all values = 256+128+0+0+0+0+0+0
this number requires 9 bits - and since a byte is 8 bits, we require 2 bytes
a hexadecimal number is two bytes, where each byte is shown as the decimal value - so this number in hex = 01 80