Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Will ES6 have native support for 64-bit integers and arbitrary-precision numbers? Or at least 64-bit integers? To me, this is the biggest, fundamental problem with Javascript.


Signed/unsigned 64-bit integers are on the agenda, but I think they are planned for ES7. They're being prototyped in SpiderMonkey right now.


That is great to hear! Of course if ES7 takes another 10 years...


I'm as impatient as you are :) Emulating 64-bit integers is pretty slow in modern runtimes...


solutions like http://code.google.com/p/closure-library/source/browse/closu... have been in use for many years.


Yeah there are plenty of JS libraries for large numbers, but all of them are a bit of a hack. They are not as fast as native compiler/interpreter support, and there is no obvious way to integrate the logic into other native functions such as JSON.parse and JSON.stringify. So you have to create your own JSON parser which is not as fast like I did: https://github.com/datalanche/json-bignum


If you want to use native JSON, store it as an object with a string.

{ "small": 2, "large": { "bignum": "-9223372036854775807.4237482374983253298159" } }

Then make sure to replace or treat the object as a big number. Granted, it is more busywork.


That is fine if the JSON consumer and producer are Javascript. What happens when the producer is a language that handles large numbers correctly? The numbers are rounded in Javascript.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: