Forum Discussion
A Solution to rounding in Storyline – without using Javascript
Normal 0 false false false oNotPromoteQF /> EN-US X-NONE X-NONE
I found a way to round numbers in Storyline without using Javascript. The challenge was to show whole percentage numbers from calculated decimal numbers (i.e. 33% for 1/3 and 67% for 2/3). Searching through the forums, all I could find was Javascript solutions and suggestions to submit a feature request. Not happy with either of these answers, I continued to play around.
I found that Storyline only holds 7 digits past the decimal place, and the 7th digit is rounded. So to get a rounded decimal (percentage) as a whole number, divide by 100,000, and then multiply by 10,000,000.
For example:
2 / 3 = 0.6666667 (rounded at the 7th position by Storyline)
0.6666667 / 100,000 = .000006666667 (which is rounded to 0.0000067)
0.0000067 * 10,000,000 = 67
Now we have our rounded 67% from 2/3
You should be able to apply this to any number you want to round. Divide and then multiply by a multiple of 10 that is large enough to push the number you want to round to the 7th position past the decimal (i.e. 13,567 / 10,000,000,000 * 10,000,000,000 = 14,000)
- JoelObrecht-033Community Member
It would be great if Storyline could add a rounding operator !!! For time calculations it is a must !!!
...
In my usecase, I used a rounding scale of triggers :
If RawVar > 1, affect 1 to RoundedVar
If RawVar > 2, affect 2 to RoundedVar
And so on...
In my case it's OK because it is a countdown timer using Project.Elapsed.Time divided by 60 000 and I wanted the time without funny decimals.
- JoelObrecht-033Community Member
Finally, I found that just hiding the decimals is easier to maintain. Not ideal, but works.