fponticelli / thx.format

Formatting library for Haxe.
http://thx-lib.org
MIT License
21 stars 8 forks source link

function value in DecimalFormat is broken #22

Open starburst997 opened 5 years ago

starburst997 commented 5 years ago

Leaving that here but on line 651 of DecimalFormat it will brake in some circumstances:

p[0] = p[0].substring(0, p[0].length-1) + (Std.parseFloat(p[0].substring(p[0].length-1)) + 1);

If you have a number like 89.99999999998, it becomes 810 (89 become '8', and 9 + 1 become 10, '8' + 10 = '810')

starburst997 commented 5 years ago

I guess, why not simply use Math.round(decimal); ? Is it because by using string manipulation it can handle numbers that goes above Float?