Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bug Report

Advisor ,
Dec 06, 2017 Dec 06, 2017

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...

871
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Dec 07, 2017 Dec 07, 2017

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

...
Translate
Community Expert ,
Dec 06, 2017 Dec 06, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2017 Dec 07, 2017

I did follow up later with a formal report.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 07, 2017 Dec 07, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2017 Dec 07, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 07, 2017 Dec 07, 2017

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2017 Dec 07, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 07, 2017 Dec 07, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 07, 2017 Dec 07, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 07, 2017 Dec 07, 2017
LATEST

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources