DigitsTolType
Digits TolType
This describes an alternative way for determining the tolerance type based on the number of digits.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl" ); TEXT(beginproblem()); |
Initialization: The tolType of type digits is built-in to MathObjects. |
Context("Numeric") Context()->flags->set(tolType => 'digits', tolerance => 3, tolTruncation => 1); $answer = Real("pi"); |
Setup:
The goal is that the student must enter at least the first
If the student enters additional digits, the first additional Warning: this tolerance type also applies to formula comparisons. For example if the answer is 2^x and a student enters e^(0.69x), this will probably not be accepted. Random test values will be used for x to make that comparison. For example if one of the test values is x=2, the correct output is 4 and the student's output would be 3.9749... and this would be declared as not a match, since the first three digits to not agree. |
BEGIN_PGML This section is with [|tolTruncation|] set to true (1). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer} END_PGML |
First Section: This tests the default conditions for this tolerance type. It should accept 3.14, 3.141 and 3.142 as correct, but not 3.15. |
Context("Numeric"); Context()->flags->set(tolType => 'digits', tolerance => 3, tolTruncation => 0); $answer2 = Real("pi"); |
Second block explanation: First, reset the context with |
BEGIN_PGML This section is with [|tolTruncation|] set to false (0). The exact answer is [`\pi`]. Enter 3.14, 3.15, 3.141, 3.142 to see if it accepts the answer. [`\pi=`][_]{$answer2} END_PGML |
Second Section: This tests when |
Context("Numeric"); Context()->flags->set(tolType => 'digits', tolerance => 3, tolTruncation => 0,tolExtraDigits => 2); $answer3 = Real("3.14"); |
Second block explanation: First, reset the context with |
BEGIN_PGML This section is with [|tolTruncation|] set to false (0) and [|tolExtraDigits|] set to 2. Enter 3.1415, 3.1416, 3.1417, 3.14888, 3.14, and 3.1415888 to see if it accepts the answer. [`\pi=`][_]{$answer3} END_PGML |
Third Section: This additionally tests when |