Variable Help

Nov 08, 2013

I have set up some numeric variables and triggers to do multiplication and my output comes out with 2 decimal places. for example

Learner inputs 350 products sold which is then divided by 42 (number of products yielded per case of sauce) and gets the result of 8.33. This means the learner would need to order 8.33 cases of sauce to make the 350 products. The problem is that the learner can not order partial cases and would need to round up to the next case,

What I would like to do is strip out the decimal places and have the answer round up to the next highest value. In this example 9. 

Is this possible?

13 Replies
OWEN HOLT

The concept is the same.

Step 1: Divide by 10,000,000 and your decimal place will move 7 spots to the left. Storyline will round that last position. 

Examples: 

  1. 189.678543 becomes 0.0000190
  2. 8.33 becomes 0.0000008
  3. 12.5 becomes 0.0000013

Step 2: Multiply by 10,000,000

Examples from above:

  1. 0.0000190 becomes 190
  2. 0.0000008 becomes 8
  3. 0.0000013 becomes 13
I think that fits the requirement.....
Michael Hinze

Danny Evans said:

Michael Hinze said:

You could use a JavaScript with the ceil() method (some info here) to round up your numbers, like in this example.


That sounds like it will work but I am not sure how to make javascript work. Can you provide the story file from your example and let me look at it for reference? 


See attached .story file. Hope that gets you started.

Danny Evans

Michael Hinze said:

Danny Evans said:

Michael Hinze said:

You could use a JavaScript with the ceil() method (some info here) to round up your numbers, like in this example.


That sounds like it will work but I am not sure how to make javascript work. Can you provide the story file from your example and let me look at it for reference? 


See attached .story file. Hope that gets you started.


That is totally awesome and totally worked.  You are a life saver.  Thanks so much..

Michael Hinze

Danny Evans said:

Michael Hinze said:

Danny Evans said:

Michael Hinze said:

You could use a JavaScript with the ceil() method (some info here) to round up your numbers, like in this example.


That sounds like it will work but I am not sure how to make javascript work. Can you provide the story file from your example and let me look at it for reference? 


See attached .story file. Hope that gets you started.


That is totally awesome and totally worked.  You are a life saver.  Thanks so much..


Hi Danny, glad to hear that file works for you.

OWEN HOLT

I just tried a non-java solution that works fine. 
I have a numeric text entry field where you can enter your number with the following triggers:

  1. Add 0.49 to NumericEntry when the control looses focus. (Any decimal below .5 will become greater than .5 as a result but a whole number will still be below the .5 decimal threshold and will not be rounded up).
  2. Divide NumericEntry by 10000000 When the control looses focus. (Step one of rounding by taking advantage of storylines 7 decimal places limit.)
  3. Multiply NumericEntry by 10000000 when the control looses focus. (Step two of rounding.)

This will work as long as you don't have a number with a decimal point of .0099999 or lower.

This would only occur at the following thresholds:

1 / >100

2 / >200

3 / >300

etc.

But since you control the equations.... you can avoid this issue.

This discussion is closed. You can start a new discussion or contact Articulate Support.