6 ms·
Who does integer math in JS with numbers larger than 9007199254740991? The examples in paragraph 1 are moot. An ID doesn't have to be represented with integers
by nom 9y ago
Who does integer math in JS with numbers larger than 9007199254740991?
The examples in paragraph 1 are moot. An ID doesn't have to be represented with integers locally (it's probably because the server stores it as 64 bit ints) and a string is perfectly fine here. Furthermore, "financially technology" working with such large numbers in JS? Are you kidding me?
Edit: downvote without an answer to my question? very helpful.
- koolba 9y agoA simple use case is incrementing a >53-bit integer id.
- nom 9y agoWhen you need incremental ids that large, you're doing something wrong. At the current rate (6000 tweets per second), twitter will run for >47600 years with 53 bit.
- koolba 9y agoSure if you only have one system generating the ids. Once you deal with distributed systems, you need some "fat" to prevent duplicate ids from being generated. That's usually done with an N-bit prefix identifying the server plus a time stamp prefix.
- Udik 9y agoThere, problem solved for both the developers that need it: https://www.npmjs.com/package/big-integer https://www.npmjs.com/package/big-integer :)
- idbehold 9y agoThe thing is that the API would still have to send them as strings even with this new ES feature because JSON doesn't support it.
- TazeTSchnitzel 9y agoAnyone dealing with data produced by other languages which uses 64-bit integers. Easy examples include tweet IDs (broken in JavaScript, because JS can't handle 64-bit integers), POSIX inode numbers (broken in node.js, because JS can't handle 64-bit integers), etc.