###

» Thu May 24, 2012 2:01 pm

@ranma is right and because computers are not perfectly precise the result is actually -1.8369701987210297e-16. The confusing thing here is that when adding floats to strings, Construct 2 rounds numbers to about the nearest billionth before adding to the string. The motivation for this is again floating point inaccuracy: if you say "Every tick, add 0.3 to a variable" and set a text object to the result, due to rounding errors eventually you'll get something like 2.999999999999997. Often due to small sized text objects which cannot fit a lot of digits this means the number disappears completely, and we get users reporting it as a "bug". So with a very very small amount of rounding, it continues to appear as expected and you get "3". In this case the result is such a small number you just get "0".

The exception is the str() expression which does not do any rounding. If you display str(cos(270)), you'll see the real answer.

The Array object does floor() on floats passed as indices, so presumably -0.000000000000000183... is floored to -1, which returns 0.

Solution: round the indices yourself. This is standard practice in programming - whenever you want to use a floating point number as an integer, it's best to round it or floor it explicitly so you get better behavior.Ashley2012-05-24 14:02:57