Hacker News new | ask | show | jobs
by z3t4 3651 days ago
Why don't they "fix" the numeric system to be more exact? I'm talking about the float implementation. I don't think anyone depends on the floating point rounding errors. But we do spend a lot of time avoiding them. They totally "screwed up" the syntax in 2015, with many breaking changes, so why not fix the damn rounding errors!?
1 comments

Because the system JS uses is an ISO standard, it is a problem not just for JS, it works for the majority of use cases, and implementing a second number system (the old one will have to be kept forever) increases cost and complexity significantly without showing enough benefits, since those who need something different can do so.

For example, if you do "money-math" you could just use only integers (use cents instead of dollars) - your number will be an integer as long as it's a whole number and you re,main below Number.MAX_SAFE_INTEGER (http://www.2ality.com/2013/10/safe-integers.html). That's not enough for big-finance math where fractions of cents matter, but for most such applications it is.