WeBWorK Problems

Option for number of digits displayed in answer preview?

Option for number of digits displayed in answer preview?

by Monika Keindl -
Number of replies: 2
It seems that if I use MathObjects' answer evaluator ANS($a->cmp); the answer preview displays only 6 digits of the typed in number i.e.

1234.5678 is displayed as 1234.57
12.345678 is displayed as 12.3457

If I use the old ANS(num_cmp($a)); the answer preview displays all digits entered.

Is there a way to adjust the length of digits displayed in the answer preview in MathObjects?
In reply to Monika Keindl

Re: Option for number of digits displayed in answer preview?

by Davide Cervone -
The number format used by MathObject is controlled by the Context()->{format}{number} setting. By default, it is "%g", which means use at most 6 significant digits, stripping trailing zeros, and use exponential notation if needed. You can change this to any printf-style print formatting string. For example, use "%.5f" for fixed-point notation with 5 decimal places.

If you set it to the empty string, the full unrounded value of the number will be used (like in num_cmp).

Hope that does the trick for you.

Davide