
BigInt: arbitrary-precision integers in JavaScript - tosh
https://developers.google.com/web/updates/2018/05/bigint
======
zzo38computer
I 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.)

------
nimish
Let'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
As this isn't my realm of expertise, I'm curious to understand how bigint
would fail to meet your needs.

~~~
nimish
There'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
Are you performing arithmetic on 64 bit "IDs?" That seems unlikely, so where
would any savings come from?

~~~
nimish
Comparisons and constructing indexes, and hashing. All need the ALU. And of
course we use them for bitmaps.

