I have a custom answer checker that's part of a custom context I am working on. Part of this contest is trying to disallow decimal answers only when they happen to be exactly correct. So for example if the real answer is something like Formula("1/2") then I would have it accept "0.5". If the answer is Formula("1/3") then ideally there should be no acceptable decimal answer that could be typed. But I don't want to simply mark "0.33" as wrong. I want to pass an error message that decimal approximations are not accepted. Again, if they enter 0.5 for 1/2, in that case I just want to let it through.
There's a lot more going on in this context, but this is the aspect where I am hitting a puzzle.
In the answer checker, I look in the answer hash to see $ans->{student_formula}, and assess if they even entered a decimal answer in the first place. (I'm using the patter match /\s*[\+\-]?\d*\.\d+\s*/.) If they entered a decimal number, I move into doing this special decimal checking outlined above. If not, I skip this and do other things with their answer.
I expected that I could get the perl real version of their answer, and the perl real version of the correct answer, do a comparison, and it would not use MathObject fuzzy comparison. So for example, I would condition like:
if ($student->value == $correct->eval()->value)
{award credit} #because their decimal answer is an exact match with the correct answer
else
{return a message that decimal approximations are not OK}
#because they entered a decimal and it was not an exact match
But that conditional ($student->value == $correct->eval()->value) is working out to be true under fuzzy real equivalence conditions. For example, with a correct answer of Formula("3/8") (with reduceConstants=>0) and a student answer of 0.3751, it results in true.
So it seems the == operator is promoting the operands to Real() and using fuzzy comparisons. Or something else that I don't understand.
My root question: how should I do an exact value comparison between two Real()s without changing the context tolType and tolerance?