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
94
S
33
G
114
Posts: 5,357
Reputation: 73,775

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
399
S
236
G
89
Posts: 24,525
Reputation: 195,382

Previous

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests