DOCUMENT(); loadMacros( "PGstandard.pl", # Standard macros for PG language "MathObjects.pl", "PGML.pl", 'nondecimal_base.pl', 'contextArbitraryString.pl' ); # The ArbitraryString context is used since numbers in bases > 10 are given in strings. # This context allows any string to be used in both the Compute and in student answers. Context("ArbitraryString"); TEXT(beginproblem()); $a = random(30,50); $a_2 = Compute(convertBase($a, to => 2)); $b = random(30,50); $b_5 = Compute(convertBase($b, to => 5)); $c = random(70,100); $c_8 = Compute(convertBase($c, to => 8)); $d = random(115,150); $d_12 = Compute(convertBase($d, to => 12)); $e = random(150,250); $e_16 = Compute(convertBase($e, to => 16)); $aa = random(30,50); $aa_2 = Compute(convertBase($aa, to => 2)); $bb = random(30,50); $bb_5 = Compute(convertBase($bb, to => 5)); $cc = random(70,100); $cc_8 = Compute(convertBase($cc, to => 8)); $dd = random(100,150); $dd_12 = Compute(convertBase($dd, to => 12)); $ee = random(150,250); $ee_16 = Compute(convertBase($ee, to => 16)); $ff = random(100,200); $ff_12 = Compute(convertBase($ff, to => 12, digits => [0..9,'T','E'])); $gg = random(100,200); $gg_12 = Compute(convertBase($gg, to => 12, digits => [0..9,'T','E'])); BEGIN_PGML Conver the following numbers in decimal to their value in the given bases: 1. [$a] = [__]{$a_2}[`_2`] 2. [$b] = [__]{$b_5}[`_5`] 3. [$c] = [__]{$c_8}[`_8`] 4. [$d] = [__]{$d_12}[`_{12}`] 5. [$e] = [__]{$e_16}[`_{16}`] Convert the following numbers in the given base into it's decimal equivalent: 1. [$aa_2][`_2`] = [__]{$aa} 2. [$bb_5][`_5`] = [__]{$bb} 3. [$cc_8][`_8`] = [__]{$cc} 4. [$dd_12][`_{12}`] = [__]{$dd} 5. [$ee_16][`_{16}`] = [__]{$ee} Convert the following numbers between decimal to base-12 using the digits T and E for ten and eleven. 1. [$ff_12][`_{12}`] = [__]{$ff} 2. [$gg] = [__]{$gg_12}[`_{12}`] END_PGML ENDDOCUMENT();