A. Background Facts:
1. A base X numeral is an abbreviation for a polynomial in x, like 5x3 +3x2 +0x1 +4x0 (Recall x0 =1.)
Examples:
| Base | Digits |
| 2 (Binary system) | 0, 1 |
| 10 (Decimal system ) | 0.1.2.3.4.5.6.7.8.9 |
| 16
(Hexadecimal system or hex for short) |
0.1.2.3.4.5.6.7.8.9,A,B,C,D,E,F
A-F correspond to the base 10 numerals of 10-15 respectively |
| 3 | 0,1,2 (There was an interesting recent article showing that computers using base 3 system for storing data had certain efficiencies compared to binary based computers and thus could be made to run faster than computers based on the binary system.) |
For thought: what are the digits
for base 8?
B. CHANGING BASE: Base x to base
10 , or base 10 to base x
Example: convert 14 to base 2 numeral.
1. (In the following " y/x " means
use integer long division to divide.)
14/2 = 7, R = 0
7/2 = 3, R = 1
3/2 = 1, R = 1
Stop as last quotient < 2 (the divisor, which is the base desired)
2. Numeral: Read the last quotient followed
by the R values reading from bottom to top:
Base 2 numeral = 1110.
3. CHECK by converting your answer to base
10:
1110 in base 2 is 1(8) + 1(4) + 1(2) +
0 = 13, the original base 10 numeral
Example: convert 30 to base 16 numeral.
1. (In the following " y/x " means
use long division to divide.)
30/16 = 1, R =14=E in base 16
Stop as last quotient <16.
2. Numeral: Read the last quotient followed
by the R values reading from bottom to top:
Base 16 numeral = 1E.
3. CHECK by converting your answer to base
10:
1E in base 16 is 1(16) + 14(1) = 16+14
= 30, the original base 10 numeral
First change from given base to base 10 (expand) and then base 10 to the desired base (by dividing by desired base).
Hex to Binary:A. More Background Facts:
1. Convert each Hex digit to a FOUR DIGIT base 2 numeral in order. (Use decimal numerals and convert to base 2 as an intermediate step if that helps.)
2. Resulting string is the binary numeral.
3. Check by converting original hex numeral and binary numeral to base 10. The resulting two base 10 numerals should be the same.Example: Convert hexadecimal A1 to binary.
1. A1 is A followed by 1. A is decimal numeral 10, which is binary numeral 1010. 1 is 1 in both hex and binary--see above table of digits. But 1 expressed as FOUR digits is 0001.
2. Hence the binary numeral is 10100001.
3. Check:
Hex A1 as decimal numeral is 10(16)+1 = 161
Binary 10100001 as a decimal numeral = 128 + 32 +1 = 161Binary to Hex:
1. Start at the right end of the binary numeral and read to the left, marking off groups of 4 binary digits until you have no more digits. (If in the last, or leftmost, group of digits you have less than four, you really do have four as you have leading zeros.)
2. Rename each 4-digit numeral as a hex numeral. (Use base 10 arithmetic to help as needed.) The resulting string is the hex numeral.
3. Check by converting the original binary and the new hex numeral each to base 10. The resulting base 10 numerals should be the same.Example: Convert 101101 to hex.
1. Grouping, starting at right: 0010 1101 (note that to get 4 digits in the leftmost group I had to supply two leading zeros.)
2. 0010 is base 10 digit 2 which is base 16 digit 2
1101 is base 10 numeral 13, which is base 16 digit D
The hex numeral is 2D.
3. Check:
101101 = 32+8+4+1 = 45
2E = 2(16) +13 =32+13 = 45Changing Bases for Fractions
Base 10 numeral 101.11 is the abbreviation
for 1(100) + 0(10) + 1(1) + 1(1/10) + 1(1/100)
Base 2 numeral 101.11 is the abbreviation
for 1(4) + 0(2) + 1(1) + 1(1/2)
+ 1(1/4)
B. Changing Base x decimal fraction to Base 10 fraction or decimal fraction
Write Base x decimal in expanded form and do arithmetic. Answer is the base 10 numeral. (This is recipe we always use to change from base "any number" to base 10.)C. Changing Base 10 fraction to Base 2 decimal fractionExample: Change base 2 numeral 101.11 to base 10.
101.11 = 1(4) + 0(2) + 1(1) + 1(1/2) + 1(1/4) = 5 3/4, or 23/4 or 5.75Example: Change base 3 numeral 20.1 to base 10.
20.1 = 2(3) + 0(1) + 1 (1/3) = 6 + 1/3
Answer: 6 1/3, or 19/3, or 6.3333.... , or 6.3 (note that the digits that repeat are underlined).
Negative numbers: Ignore the sign for changing purposes and apply the sign to the final answer. Example: Hex -1A expressed as base 10 is -(16 + 10) = - (26) = -26. Binary -10 as base 10 numeral is -(2+0) = -2.
- Base 10 fraction is written as fraction whose denominator is a power of 2: Expand in powers of 2. Check: Convert on calculator the original base 10 mixed fraction to decimal form. Expand decimal in base 2 and perform operations on calculator. The two decimal forms should be the same.
Example: Express 13/4 or 3 1/4 (read " 3 and one fourth") as a binary decimal.
3 1/4 = 3 + 1/4 = 1(2)+1 + 0(1/2) + 1(1/4) = 11.01 in base 2.
Check: 3 1/4 = 3.25 11.01 in base 2 = 1(2)+1+0(1/2)+1(1/4) = 3+.25= 3.25
.- Base 10 fraction is written as a fraction whose denominator is NOT a power of 2: Convert the base 10 numeral to decimal form and continue as below, (provided original decimal representation is terminating).
.- Base 10 fraction is written as a decimal:
1. Write the fraction as the sum of the integer part plus the decimal part.
2. Convert the integer part to binary as usual--see above.
3. Convert the decimal part to binary as illustrated below in changing each of 3.8125 and 3.8 to binary numerals. Note that we stop the process when either we see all 0's when we record all but the integer part of the results of multiplication OR we see the pattern of multiplication repeat. In the first case the decimal terminates; in the second it repeats--just like base 10!
4. The fractional part of the binary numeral will be the sequence of recorded 1's and 0's read from the first one recorded to the last one recorded.
5. Combine the binary integer and fraction parts to get the binary representation.Example: Convert 3.8125 to binary
1. 3.8125 = 3 + .8125
2. 3 converts to 11.
3. Now convert .8125 to binary:
2x.8125 = 1.625--> 1 (record the integer part)
.625 (record all but the integer part)
2x.625 = 1.25 --> 1 (record the integer part
.25 (record all but the integer part)
2x.25 = .50 --> 0 (record the integer part--it is 0 as .50 = 0.50)
.50 (record all but the integer part)
2x.50 = 1.00 --> 1 (record the integer part)
0.00 (record all but the integer part)
STOP as we see only 0's when we write the noninteger part of the results of multiplication.
4. .8125 converts to .1101.
5. 3.8125 = 3 + .8125 = binary (11 + .1101) = 11.1101, the binary numeral.
Example: Change 3.8 to binary1. 3.0 = 3 + .8
The above recipe is based on the fact that the only way we can get binary .1xxx... is for the original decimal part to be at least .5. (Why? Because .1xxx... means we have 1(1/2) + stuff.) The only way to get binary .0xxx... is for the original decimal part to be less than .5. (Why? Because .0xxx..means we have 0(1/2) + stuff, and the sum represented by stuff is less than 1/2.)
2. 3 converts to 11.
3. Now convert .8 to binary:
2x.8 = 1.6--> 1 (record the integer part)
.6 (record all but the integer part)
2x.6 = 1.2 --> 1 (record the integer part
.2 (record all but the integer part)
2x.2 = .4 --> 0 (record the integer part--it is 0 as .50 = 0.50)
.4 (record all but the integer part)
2x.4 = .8 --> 0 (record the integer part)
.8 (record all but the integer part)
2x.8 = 1.6 --> 1 (record the integer part)
.6 (record all but the integer part)
Aha, note that we are back with 2x.8. Hence, we are starting to repeat the sequence.
STOP as we see repeating pattern.
4. .8 converts to the repeating binary decimal .1100 1100 1100 .... or .1100
5. 3.8 = 3 + .8 = binary (11 + .1100) = 11.1100 , the binary numeralFood for thought: Suppose we want to change 6.08 to a base 5 numeral. How do you think the recipe above changes? (Hint: consider what binary .4, .3, .2, .1, .0 mean about the original decimal part.)