# caret.pg
# Philip D Loewen, 2021-09-12
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserPopUp.pl"
);
TEXT(beginproblem());
Context("Numeric");
$two = 2;
$three = 3;
$a = $two^$three;
$b = Formula("$a");
$c = Formula("$two^$three");
##############################################################
BEGIN_PGML
The code to set up this problem says
```
Context("Numeric");
$two = 2;
$three = 3;
$a = $two^$three;
$b = Formula("$a");
$c = Formula("$two^$three");
```
Find [|$a|]: [___________]{$a}
Find [|$b|]: [___________]{$b}
Find [|$c|]: [___________]{$c}
END_PGML
BEGIN_PGML_SOLUTION
In Perl, the caret ([|^|]) is a binary operator that computes the bitwise exclusive-or of its inputs. Therefore [|$a|] is the result of something like [|0b0010 ^ 0b0011|], namely [|0b0001|].
Perl does string interpolation inside double-quotes, so the line defining [|$b|] is equivalent to [|Formula("1");|].
Inside a formula string WeBWorK conventions apply. There, the caret denotes exponentiation. The line defining [|$c|] is equivalent to [|Formula("2^3");|].
Users influenced by algebraic thinking may find the difference in results for [|$b|] and [|$c|] surprising, and therefore instructive.
(For reliable exponentiation, the two-character operator "[|**|]" appears to work in all cases.)
END_PGML_SOLUTION
ENDDOCUMENT();