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)
- MitchHayashiCommunity Member
Hi Anna,
If you are getting 1% when you expect 0% my guess is that you are using "greater or equal to" instead of "greater than" when comparing your floorScore variable vs Storyline's Results.ScorePercent variable. If you post a project file with the triggers you are using I will take a look at it.
- AnnaGorshkovaCommunity Member
Hi Mitch,
Thank you so much for reaching out! I don't believe I had any triggers that were set to "greater or equal to."
I was able to navigate around the 1% by adding a trigger to set the floorScore equal to the value of the Results.Score.Percent if Results.ScorePercent was 0 (similar to the 100% trigger).
I attached all of my slide triggers. There shouldn't be any problem with adding this additional trigger, correct?
Thank you again.
- MitchHayashiCommunity Member
Hi Anna,
The reason you are getting 1% instead of 0% is because you are using the first version I posted which does not work for 0% for many reasons. The new trigger you added that sets floorScore to Results.ScorePercent if Results.ScorePercent equals 0 will work to correct this in most cases.
However, I recommend you use the corrected and simplified version in the edit to my original post that uses only one variable and two triggers.
- AnnaGorshkovaCommunity Member
Hi Mitch,
Got it. Thank you again for posting your helpful solution!
Anna
- TerryArthur1Community Member
I have a similar issue, but I am not using a results slide. I am creating a conversion for Fahrenheit to Celsius and the math gives me a decimal. I have tried to incorporate the math above, but it still gives me the decimal. Does it only work on the results slide?
- DavidPrice-D1Community Member
I am having a similar problem as Terry. I am actually trying to show a percentage on a progress indicator and I need to strip off the 2 decimal places. I don't need to round it (but it would be handy), I just dont want a progress indicator showing x.xx%
I have been right through this thread and tried the different solutions to no avail :(
- TerryArthur1Community Member
David…
I finally had to use the Java solution and it works great…
2 days ago
Hello! This is what I use to round - add a trigger to execute this Java.
I usually have a variable that contains the answer, then I pass it to another variable, then run it though this script. NumberYearCalc is my answer that was passed. And RNDofNumberYearCalc is my new variable that the rounded number will be passed to.
var player = GetPlayer();
var JSRounded=Math.round(player.GetVar("NumberYearCalc"));
player.SetVar("RNDofNumberYearCalc",JSRounded);Thank you,
Terry Arthur
Training Development Analyst
Rinnai America Corporation
103 International Drive
Peachtree City, GA 30269
Phone: 800.621.9419 x4361
Direct Dial: 770.632.4361
Email: tarthur@rinnai.us
Web site: www.rinnai.us
Training site: www.trainingevents.rinnai.us
twitter: www.twitter.com/rinnai
facebook: www.facebook.com/rinnaiamerica
Rinnai America Corporation
Why Rinnai?
- DavidPrice-D1Community Member
Terry you are an absolute legend, it works perfectly :D
Only problem is it wont work for my mobile users, but hopefully that's only a small portion of people
- beckygrayCommunity Member
thank you so much - it works! this was doing my head in!!!
- ShaneHille-8d26Community Member
When using the method of the Floorscore by Mitch will the LMS pick up that score as the resultscore? If not, the LMS will still show a non rounded grade right?
Reason im asking is, we have developed a course but it is not running in our own LMS. Every score with a decimal I.E. 66,78 is registered as 6678% instead of 66,78%.
- DaceAkmeneCommunity Member
Hi everyone,
I tried many suggestions but none worked for me. If understand correctly the newest version doesn't support dividing/ multiplying solution, but what about Javascript?
I tried 2 JS of here suggested but they didn't work, unfortunately.
- NatashaBomba-Community Member
Does the non-javascript solution still work? It doesn't seem to do anything for me. I have all the triggers in order but I'm wondering if there's a conflict with the "go to layer x" at the start of the timeline--ie is it jumping to the next layer before applying the changes to the variable.
- DianaMyersCommunity Member
@Natasha, assuming all the triggers are in the correct order, have you tried setting the "show layer" trigger to execute at the 0.25 second mark of the timeline? If you can share a screen shot of your trigger panel, I'd be happy to help you troubleshoot it.
- NatashaBomba-Community Member