Mathematic error

Bugs will be moved here once resolved.

Post » Sun Oct 09, 2016 4:36 am

You would only need to round it when you display the number. Another way is to just use whole numbers and convert it to a decimal only when you display it, that way no rounding is needed. I think newt was alluding to that above.

So instead of:

Global number num=0

Every 1 seconds
--- add 0.2 to num
--- set text to num

Do this:

Global number num=0

Every 1 seconds
--- add 2 to num
--- set text to num/10
B
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

Post » Mon Oct 10, 2016 11:11 am

Closing as not a bug: see 'Expecting math calculations to be exact' in Common mis-used events and gotchas.

The inaccuracy happens in your CPU circuitry and affects all software on your computer. It's the same problem as saying one third times three when you only have 6 digits of accuracy: you end up with 0.333333 * 3 = 0.999999, not 1, except recurring fractions are different in binary (and 0.2 is recurring in this case).
Scirra Founder
B
414
S
245
G
92
Posts: 25,207
Reputation: 200,355

Previous

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest