Modkit - problem adding whole numbers

Got a program that makes the robot move in a square. There is a variable called Target that starts at 90 and gets 90 added to it each time the robot makes a 90 degree turn. The variable is used to set the target for the gyro to turn to.
This variable is printed to the screen (set to 0 decimal places) and I noticed that the variable went 90 to 179 to 270 to 359 rather than 90/180/270/360. When I set it to show 5 decimal places, the actual data is 90/179.99999/270/359.99999 so something is going a bit funny with the addition where it is not adding whole numbers.

I have done some tests on the desktop and iPad versions and there is the same issue.

Hi there,

Number variables are implemented as floating point numbers and thus have some rounding error so it is not surprising that 180 can become 179.99999. And then the print function simply truncates the number to the given decimal places (0 decimals in your example) so the error you see seems more drastic.

We may make changes in future versions of Modkit to simplify integer math but I hope this helps answer why you’re seeing what you’re seeing.

Best,
Modkit