3 ms·
BigInt: arbitrary-precision integers in JavaScript
- nimish 8y agoLet's get actual integers into JS! c'mon, I can't actually represent 64 bit IDs properly! This affects a big analytics product you have probably used!
- Waterluvian 8y agoAs this isn't my realm of expertise, I'm curious to understand how bigint would fail to meet your needs.
- nimish 8y agoThere's no guarantee that it will specialize down to machine integers. I don't need arbitrary precision; I need fast, fixed precision. If the proposals guaranteed specialization I'd be much happier but I don't think they do. But it's way better than the status quo.
- millstone 8y agoAre you performing arithmetic on 64 bit "IDs?" That seems unlikely, so where would any savings come from?
- andreareina 8y agoComparison (as when doing e.g. an index scan) would still be affected, no?
- nimish 8y agoComparisons and constructing indexes, and hashing. All need the ALU. And of course we use them for bitmaps.
- zzo38computer 8y agoI think no such guarantee is needed as that is beyond the scope of the specification, I think. If you do need that you can use C or WebAssembly (or you can specifically use an implementation which guarantees it).
- zzo38computer 8y agoI agree to have big integers in JavaScript. I have read about this before (after asking about 64-bit integers in JavaScript on IRC, actually), and this is very good. That was one of the remaining problems in JavaScript, and now it is fixed. The N-API routines for dealing with bigint are still marked as experimental, but then I can make a proper JavaScript API for SQLite; each SQL type can be represented as a different JavaScript type. My "reload-form" package (which is pure JavaScript and does not use N-API) can also be corrected to tell the difference between integer nodes and floating nodes. And it can also be used with other stuff that uses unlimited big integers such as implementing some esolangs (such as Fractran). Just one thing I do not agree is the requirement that both operands of a bit shift operator need to be the same type; I think it should not be required and the type of the left operand should be used as the type of the result. (Although it isn't too serious if this isn't fixed.)