Tested on WW 2.16 and WW 2.17.
An instructor asked me about an issue with the question below from a live assignment with seed 3463 where $c (which should have at most two decimal places) is displayed as -0.780000000000001.
Is such an error type to be expected once in a while?
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
);
Context("Numeric");
$showPartialCorrectAnswers = 1;
$a=non_zero_random(-20,20,0.01);
$b=non_zero_random(-20,20,0.01);
$c=non_zero_random(-20,20,0.01);
$mag=sqrt($a**2+$b**2+$c**2);
$smag=sprintf("%.6f",$mag);
@dir=($a/$mag,$b/$mag,$c/$mag);
@sdir=(sprintf("%.6f",$dir[0]),sprintf("%.6f",$dir[1]),sprintf("%.6f",$dir[2]));
TEXT(beginproblem());
BEGIN_PGML
What is the unit vector for the vector [`\langle [$a],[$b],[$c] \rangle`]?
Answer: [`\langle`][__________]{$dir[0]},[__________]{$dir[1]},[__________]{$dir[2]}[`\rangle`]
END_PGML
ENDDOCUMENT();