-
-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Sometimes when using contextCurrency.pl, there is algebra that leads to a perl decimal version of an answer, and then you pass that decimal to the Currency() constructor to create an answer where students must use a dollar sign.
Sometimes, you are creating an answer like this one: Currency(12.345). And sometimes (depending on what produced that decimal value and whatever machine rounding error may be in play) the correct answer displays as $12.35, but neither $12.35 nor $12.34 will be accepted as correct when a student enters them, using the default tolerance. They are just at the cusp of the decimal tolerance. Also a student may not enter something like $12.345 with the default flags.
Perhaps the problem author should be aware of all this and round their decimals before passing them to the Currency() constructor. But maybe not, since maybe the Currency() object is supposed to retain deeper decimal precision if it gets used in further calculations. So I'm wondering if we could address this by tweaking the cmp method for a Currency object. What I'm thinking is, if the context disallows entering more than two decimal places, the correct answer should be rounded to two decimal places before it is actually compared to the student answer. Would that idea raise any objections? Of course this is something where I'm interested to hear from @dpvc.