Stack Number of Decimal Places Comparison

Re: Stack Number of Decimal Places Comparison

by Thorsten Bartel -
Number of replies: 1
Picture of Core developers
Hi Rodrigo,

I'd like to draw your attention to the following documenation page:
https://github.com/maths/moodle-qtype_stack/blob/master/doc/en/CAS/Numbers.md

You might want to pay special attention to the paragraphs titled "Maxima and floats with trailing zeros".
I was not able to preserve trailing zeros with any input type through further operations / calculations. This might only apply to

The next best thing you can do is string manipulation and evaluation. Let x,y be your students input (input type should be "String"):
xdec: split(x,".");
xlen: length(split(xdec[2], ""));
ydec: split(y,".");
ylen: length(split(ydec[2], ""));
diff: xlen - ylen;

The first line splits the input string at the delimiter "." (decimal point).
The second line then takes the second part of this split operation (the right-hand side or decimal places) and takes an empty delimiter for the split operation, giving single characters. The length of the resulting array is the number of decimal places in your input. You can then simply compare whether diff equals zero.

Cheers
In reply to Thorsten Bartel

Re: Stack Number of Decimal Places Comparison

by Leo Butler -
I am just updating my moodle server for the fall and while testing the STACK plugin, I noticed there is a testsuite for the NumSigFig answer type.

It should be available at https://.../question/type/stack/adminui/answertests.php?anstest=NumSigFigs on your server.

Leo