I was really surprised. My intention was to format the distance to precision two. Furthermore I want to draw a small circle for each 100 m up to 500 m. I did following to format the distance:
distanceField = dist.format("%.2f");
To get the number of circles I used:
numberOfCircles = (dist*100).toNumber() % 5;
By doing this I realized that the small drew circles appeared at a different time than the distanceField increased the 100 m. I digged into that problem and realized that the format command does not only a formating of the float but also does a rounding and that's the problem. E. g. a distance of 0.03645 is rounded to 0.04.
I have this formatting in all my data fields which means that the datafields display a (small) inaccuracy. Is there a way to change the format behaviour or do I have to do a
dist += 0.005;
before I use the format command?Update: The correction value has to be
dist -= 0.004999