I replied here to exit from the nested comments.

The real grading is done by the numerical question type after substitution of the dataset items.

PHP code is used to compare the values with the MIN and MAX obtained by the following function that do not take care of significant figures.

function **get_tolerance_interval**(&$answer) {

// No tolerance

if (empty($answer->tolerance)) {

$answer->tolerance = 0;

}

// Calculate the interval of correct responses (min/max)

if (!isset($answer->tolerancetype)) {

$answer->tolerancetype = 2; // nominal

}

// We need to add a tiny fraction depending on the set precision to make the

// comparison work correctly. Otherwise seemingly equal values can yield

// false. (fixes bug #3225)

$tolerance = (float)$answer->tolerance + ("1.0e-".ini_get('precision'));

switch ($answer->tolerancetype) {

case '1': case 'relative':

/// Recalculate the tolerance and fall through

/// to the nominal case:

$tolerance = $answer->answer * $tolerance;

// Falls through to the nominal case -

case '2': case 'nominal':

$tolerance = abs($tolerance); // important - otherwise min and max are swapped

$max = $answer->answer + $tolerance;

$min = $answer->answer - $tolerance;

break;

case '3': case 'geometric':

$quotient = 1 + abs($tolerance);

$max = $answer->answer * $quotient;

$min = $answer->answer / $quotient;

break;

default:

error("Unknown tolerance type $answer->tolerancetype");

}

**$answer->min** = $min;

**$answer->max** = $max;

return true;

}

on return from **get_tolerance_interval **the function **test_response do a simple math php comparison using the $answer->min** and **$answer->max.**

return (**$answer->min** <= $response && $response <= **$answer->max** );

One way to solve the problem will be to convert **$answer->min** and **$answer->max** to **litterals** using the significant figures so to obtain **$answer->min_litteral** and **$answer->max_litteral** and convert them back to **$answer->min** and **$answer->max** as **numbers** before doing the comparison.

But a complete check of all the possible cases ( there is various issues when using very large or little numbers ex.1e-23) had to be done before putting this in the code