We have conceived a captivate project (Captivate 2017) in which learners get the oppotunity to train their ability to figure out the excact prices of differerent packages of our product.
With 8 differing package constellations given in the shopping cart the learner is asked to type in what she/he assumes as the correct price. Using an advanced action and variables after entering the learne's input will be displayed, the correct price (i.e. the right answer), and the differnce is calculated. ( 1. "Your price enty: Euro xxx.xx" / 2. "The correct price is: Euro xxx_xx" / 3. "You charged Euro xx.xx too much/too little" )
Our variable is as follows:
expression v_difference - v_correct_price - v_customer_x_input
With the learner's input of smooth amounts everything works fine. Even if the difference is 0.50 cents everything is OK. But if the learner enters a price that is by (let's say) 20 cents too much or too little the calculated and displayed differences show a very weird result:
Instead of "You charged 0.20 Euros too much" it says "You charged 0.2999999999999999716 too much".
As it is all a matter of adding or subtract amounts and nothing is divided or so these odd figures are very strange and we have absolutely no guess where the problem stems from. We have already considered a workaround using a java script that would round the calculated difference to only two digits behind the decimal mark (decimal separator). But there must be another solution to this issue.
Any qualified suggestions will be very much appreciated.
Thanks in advance
I have answered yesterday to the same question. Did you post it in the elearning community as well? Remember having posted a link to one of my blog posts where I use JS to format numbers. That will be necessary. Here is that link again: