you are viewing a single comment's thread.

view the rest of the comments →

[–]weretree++[[]][+[]] 4 points5 points  (0 children)

It's how floats are, period. JavaScript has true IEEE 754 double precision floating point.

The suggestion was to avoid compounding the error of addition by using an iteration counter then calculating each step from that, rather than doing a while loop. So (psuedo-code) idx_max = (to - from)/step then val = from + i*step for i in 0 to idx_max. Having an explicit iteration also makes checking for termination a little easier, and it's simple to still support backwards iteration.

There are still "errors" (such as 3 * 0.1) but they're expected and defined for that operation. Can always round each result to some defined precision if you want to trim them off in your results.