# Decimal Display

By
Traci P

Hi! Thanks in Advance!

I understand that the default SL functionality is to display 2 decimal places for number variables. Does anyone know if there is anything that can be edited within a scorm file to display 4 decimal places (rounded) by default? I've seen some workarounds, but they seem cumbersome to do if you were to be working on a math/finance type course with specific rules around decimals and rounding that includes several equations and a large number of problem sets.

## 5 Replies

No, there is not way to change this in Storyline.

You'll need to use one of those cumbersome workarounds...

Thanks for confirming! If you have any ideas about the best workaround to display 4 decimal places where the fourth is rounded, I’m all ears. I’ve seen people trying different ways to do this.

Actually @matthew I just emailed you instead.

Thanks Traci. I responded to your email but I'll share this here as well in case in helps someone in the future.

Here is a demo.

Here is the source file.

Here is the JavaScript used to achieve this:

For this to work, you'll need the following variables in Storyline:

`NumericEntry`

- which is a number variable. This is where the original number is entered.`FourDecimals`

- which is a text variable. This is where the four decimal number is saved.Here is a quick description of what's happening in the above JavaScript:

This solution isn't perfect.

The variable that we get back to Storyline is a text variable rather than a number variable, which means you can't then perform math related functions with it in Storyline.

In theory, this shouldn't be required, we should just be able to change the fourth line from

`var num=parseFloat(num).toFixed(4);`

to`var num=num.toFixed(4)`

; and then pass that value back to a numeric variable in Storyline. However, when I tried this approach the script wouldn't run. I also tried another approach where I used a different approach to feed the number variable back to a numeric variable in Storyline but in that case, Storyline just made it a two decimal number!However, when I tried this approach the script wouldn't run as it claimed that

`num.toFixed`

was not a function. I suspect that Storyline may have been passing the original variable as text rather than a number...I also tried another approach where I passed a number back to a numeric variable in Storyline but Storyline decided to just make it a two decimal number!

Silly Storyline.

Hope this helps.

It is actually even more mysterious. Let's say you have your number you enter as 1.1399. Once this gets into the SL variable, it's rounded to 1.14. BUT it is not the actual number stored in Storyline, it is just the number DISPLAYED.

You can test this by multiply the number (supposedly 1.14) by 1000 in JavaScript and you get 1139.9. That means SL keeps the actual 1.1399 number in the variable, it just doesn't show it.

Thanks, Zsolt, for that testing. I've added your comments to a report we have about decimal rounding with numeric variables.