Unwanted Decimal Rounding

Does anyone have a work around to keep decimals from rounding in a trigger condition?  I need a numeric entry field to have four displayed decimal points:

0.0817

This keeps rounding to 0.08.  There is no calculation needed between cells as the calculations should be made by the user on paper, but the entered results should be only rounded to four decimal places in the field.  Rounding to two is not an option.  Help!

10 Replies
Walt Hamilton

Alternatively, (if you're not a mathematician :) ) you could use a text entry box, and set the trigger to show a correct result if the input was "0.8017" or ".8017".

Just a thought, and not to disparage mathematicians. It is just that to them "0.8017" and ".8017" are not the same thing, but to Storyline, if they are in an entry box they can be the same if you don't plan to use the input to calculate.

Christopher Dawes

This solution assumes a predetermined number. What if I have Storyline (360) generating random numbers and javascripts that perform the calculations for those numbers and then compare that to the user's response? 

I have the javascript returning results tofixed(5) and storyline is round those results to two places. How can I force storyline to keep out to 5 places?

Ashley Terwilliger

Hi Christopher,

If you're using Javascript to set up a variable and looking to keep that displayed on your slide, I'll leave that to the community as it's a bit over my head! If you're trying to modify the built-in results.scorepoints variable - that isn't an accessible variable in Storyline, so that's also a great community question! 

Steve Gannon

Christopher,

Are you doing the comparison within Storyline or within JavaScript? If the latter, it should work. When the user enters the response via a numeric entry field, send that variable to JavaScript (it should retain the number of decimal places the user entered) and compare it to the random number within JavaScript.

If you then need to send a value back to Storyline and want to display that value out to five decimal places, convert the value to a string and send it back to Storyline in a separate variable.

For example, the Storyline variable going into JavaScript could be "NumValue" and the JavaScript value you send back to Storyline could be assigned to a second Storyline variable called "StrValue."

If you need to then re-use the StrValue variable mathematically, you could send it to JavaScript, convert it to a number, and so on.

Hope that gets you started!