Conversions


Decimal Counting

The decimal - or base 10 system - of counting is the most natural and intuitive form of counting to regular people. Each place corresponds to some unit of a power of 10. For instance, the first place corresponds to the 100th unit, or the ones place, as we would call it by. The second place corresponds to 101th unit, or the tenths place, so on and so forth. Take, for instance, the number 1,729. From this we can determine the values of the numbers that there is a 1 in the thousands place, 7 in the hundreds, 2 in the tens, and 9 in the ones. In decimal, only the digits 0 through 9 can be used.


The Decimal System: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Places in Decimal: 10000, 1000, 100, 10, 1

Decimal Place-Value Chart

Values
Exponent Place Notation 104 103 102 101 100
Decimal Place Notation 10000 1000 100 10 1

Binary Counting

Binary counting, also known as the base 2 system, is the most basic counting system, and is the most easily interpreted by computers. Binary is used in computers since it corresponds the most to how electricity and the hardware function: Inputs can only ever be on an ON (1) or OFF (0) basis. Binary works by having each place correspond to a power of 2, instead of 10 like in decimal. So, the second place correponds to the 21th unit, or the two's place. So, the decimal number 42 can be represented as 101010, where there is a 1 in the thirty-seconds, 1 in the eights, and 1 in the twos. Adding them together, 32 + 8 + 2 = 42. Only the digits 1 and 0 can be used.


The Binary System: 0 1 10 11 100 101 110 111 1000 1001 1011
1100 1101 1110 1111 10000 10001 10010 10011 10100
Places in Binary: 16, 8, 4, 2, 1

Binary Place-Value Chart

Values
Exponent Place Notation 24 23 22 21 20
Binary Place Notation 16 8 4 2 1

Hexadecimal Counting

The hexadecimal system - or base 16 system - of counting is the most compact system of the three, being able to store a large amount of data within a small amount of units. Each place corresponds to a power of 16. For instance, the second place corresponds to 161th unit, or the sixteenths. Since we don't have more than 10 numerical digits to use, but we need to represent 16 digits, hexadecimal uses the letters A, B, C, D, E, and F to represent 10, 11, 12, 13, 14, and 15 in decimal. When hexadecimal shows 10, it actually represents the decimal 16, since the 1 is in the sixteens place. This allows hexadecimal to store large numbers in a small amount of characters. The decimal 13579 is represented by the hexadecimal 350B, where there is a 3 in the 4096ths, 5 in the 256ths, and B (11) in the ones.

3 * 4096 = 12288
5 * 256 = 1280
12288 + 1280 + 11 = 13579

The Hexadecimal System: 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14
Places in Hecadecimal: 65536, 4096, 256, 16, 1

Hexadecimal Place-Value Chart

Values
Exponent Place Notation 164 163 162 161 160
Hexadecimal Place Notation 65536 4096 256 16 1

Converting Between The Systems

While there are methods to convert directly between each system, it's often easier for beginners to use the decimal system as an intermediary step in conversions.


To convert from a number in any base to the decimal system (base 10), you should first divide the number up into its individual places values. For an example, we will attempt to convert from binary into hexadecimal. Let's use a previous example, the binary digit 101010. After dividing the number into individual places, take the position (n) of the digit in the number, starting with the furthest right digit. That number represents the nth exponent of whichever base we are in so that each place is bn-1 where b is the base number and n is the digit's position. The digit's position is being subtracted by one since our furthest right digit must always be 1, i.e. an exponent of 0. In this case, we are in base 2 right now.

Binary Values 1 0 1 0 1 0
Exponent Place Notation 25 24 23 22 21 20
Decimal Place Notation 32 16 8 4 2 1

Take each number from the decimal place notation and multiply it with the values in the binary digit. Afterwards, add all of the results up. In this case, we do:

1 * 32 = 32
0 * 16 = 0
1 * 8 = 8
0 * 4 = 0
1 * 2 = 2
0 * 1 = 0
32 + 8 + 2 = 42

This method is effective for all bases and all numbers. Generalizing on the method, use bn-1 to determine the unit, with b as the base being converted and n as the digit's position. For instnace, the fourth place of decimal is 103, or 1000; the seventh place of hexadecimal is 166, or 16777216; the fifth place of octal is 84, or 4096; etc.


Converting from decimal into another system is rather easy as well. We simply take the method we use to convert into decimal and also some mathematical reasoning. Say we want to convert our 42 into hexadecimal. First, we write down the place-value chart for the system we want to convert into. In this case, we want to convert into base 16.

Values
Exponent Place Notation 162 161 160
Hexadecimal Place Notation 256 16 1

Find the largest digit we can subtract by and still have a positive number left. 42 cannot be subtracted by 256 and still be positive, so the value in the 256ths place is 0. 42 can be subtracted by 16. Put a 1 in the 16ths place. We now have 26. However, 26 can still be subtracted by 16. No worries, just subtract by 16 again and add 1 to the 16ths place. The 16ths place will now have a 2 in it, and we now have 10. Repeat the same steps for the 1s digit - 10 will be subtracted 10 times. Therefore, a (which stands for 10) will go in the 1s digit. We now have zero, and we are done. Remove all leading zeros.

Values 0 2 a
Exponent Place Notation 162 161 160
Hexadecimal Place Notation 256 16 1

We've now just converted 42 into hexadecimal. The decimal digit 42 is 2a in hexadecimal. Again, this method can be generalized to any base, just use the corresponding place-value chart.


Conversion Practice

Decimal and Binary

Example 1: Convert 150 into Binary
Example 2: Convert 1010100 into Decimal

Decimal and Hexadecimal

Example 3: Convert 1984 into Hexadecimal
Example 4: Convert 6b into Decimal

Hexadecimal and Binary

Example 5: Convert ab into Binary
Example 6: Convert 11101110 into Hexadecimal

Challenge: 154 is a digit in Octal (base 8). Using our methods, you should be able to convert this into Hexadecimal.
Example 1: 10010110
Example 2: 84
Example 3: 7c0
Example 4: 107
Example 5: 10101011
Example 6: ee
Challenge: 6c

Extras


As a special treat, enjoy this video about number systems, character encoding, and YouTube's Video ID system by Tom Scott: