Copy link to clipboard
Copied
I believe I have discovered a bug in Captivate v9.0.2.437
A little background...
I was tinkering with an idea where the user can manipulate various settings that are used to determine the capacity of a scale.
The numbers across the top are called graduations, the left side represents the decimal place location, and the right side represents the size of the increment.
In essence, the math is simple - the increment and decimal location are multiplied together to create the "count-by". This is then multiplied by the number of graduations to create the capacity. The default in this scenario is 10000 graduations with a count-by of 1. This means the scale would count up 1, 2, 3, 4, 5, etc.
The user can select the various choices provided. Each selection assigns the appropriate value to a variable and calculates the capacity and displays it in the window of the scale weight indicator. The idea is for the learner to simply play with the combinations and see their relationship to one another to help develop understanding.
Now the bug part.
In the video, you can see me go through several selections but for some reason, the combination of 4 decimal places, 7000 graduations, and 1 or 2 divisions creates a lot more zeroes when the calculation is performed. I placed a few text boxes on top to show the variables being updated. The two values at left are simply multiplied together to come up with the value on the right using an expression. The expression works fine with all the other combinations.
Unfortunately, I don't see anything I can do on my end to correct this...
Well in JavaScript 7000 * 0.0001 = 0.7000000000000001
So I don't see this as being a bug if Captivate is using JavaScript to do the calculation.
The issue is with floating point decimals an mapping them to a binary representation.
If you want this to work correctly you are going to need to use JavaScript yourself to do the calculations and either round or use fixed decimal places.
I don't know how you are doing the calculations, if in an advance action or not, But even if you are using an advanced a
...Copy link to clipboard
Copied
If you believe this to be a bug, you should really be reporting it using the Bug Reporting form linked to the Captivate Community page. Opening a thread here on the User Forum doesn't do the same thing. However, the thread might allow someone to suggest a workaround you can use.
Copy link to clipboard
Copied
I did follow up later with a formal report.
Copy link to clipboard
Copied
What are the calculations you are using to get the value with all of the zeros?
It might be beneficial to use JavaScript, Captivate is doing that anyway, so you can control the rounding of values or to display a fixed amount of decimal places
Copy link to clipboard
Copied
It is just varC = varA * varB
You can see the numbers at the top in the video being multiplied together.
The only issue is with 7000 * 0.0001 and 7000 * 0.0002
All the others work fine.
Copy link to clipboard
Copied
Well in JavaScript 7000 * 0.0001 = 0.7000000000000001
So I don't see this as being a bug if Captivate is using JavaScript to do the calculation.
The issue is with floating point decimals an mapping them to a binary representation.
If you want this to work correctly you are going to need to use JavaScript yourself to do the calculations and either round or use fixed decimal places.
I don't know how you are doing the calculations, if in an advance action or not, But even if you are using an advanced action you could always add this simple JavaScript as the last step.
window.yourVariableName = Number(window.yourVariableName).toFixed(1);
or
window.yourVariableName.toFixed(1)
Copy link to clipboard
Copied
Well, Captivate seems to properly calculate and render all the others.
Why do you suppose the calculation is not consistent?
If you don't see this as a Captivate bug... is it a javascript bug?
One of these kids is not like the others...
1000 x 0.0001 = 0.1
2000 x 0.0001 = 0.2
3000 x 0.0001 = 0.3
4000 x 0.0001 = 0.4
5000 x 0.0001 = 0.5
6000 x 0.0001 = 0.6
7000 x 0.0001 = 0.7000000000000001
8000 x 0.0001 = 0.8
9000 x 0.0001 = 0.9
Copy link to clipboard
Copied
It is not only a JavaScript "bug", but Python and many other languages. It's because of floating point decimals and converting them to binary in a compiler.
The code snippet I gave you fixes the issue though.
Copy link to clipboard
Copied
The snippet did take care of the issue.
I have a long journey ahead of me if I am going to learn javascript coding.
I actually had courses in HTML, CSS, and PHP and have had a little exposure to javascript so the idea doesn't scare me.
I suppose I may have sufficient reason to dive into it further.
I would prefer that Captivate simply rendered it like the others so I did not have to resort to applying "band-aids".
It already takes plenty of time to think through all the logic of conditional advanced actions as it is without doing a bunch of code on top.
Nonetheless, thank you for the code.
I would never have come up with that on my own.
Copy link to clipboard
Copied
I don't use advanced actions, I just use JavaScript as I can code the way I want and make it dynamic and reusable.
The problem with Captivate not displaying it the way you want, is that it would be very hard to write code trying to decipher what each user would need and if there actually was an issue with a calculations to begin with. The more things like that written into the code the more of a hit on performance.
Just in case the toFixed() truncates too much, the number in the parens is the number of decimal places.