Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native 64bit integers in Javascript

Tags:

javascript

It seems that even the newest Ecmascript 8 has no support for 64bit integers.

Currently we have to use libraries, like Long or UInt64 or Closure Library.

Is it technically possible to add native support for 64bit integers in Javascript?

like image 295
Timo Kähkönen Avatar asked Aug 27 '17 19:08

Timo Kähkönen


People also ask

What is 64-bit integer in JavaScript?

Every Entity within an IModel is identified by a unique 64-bit integer Id. Since JavaScript does not natively support 64-bit integers, 64-bit Ids are instead represented as strings. Strings containing 64-bit Ids are distinguished from ordinary strings through use of the Id64String type alias.

Are JavaScript numbers 64-bit?

The JavaScript Number type is a double-precision 64-bit binary format IEEE 754 value, like double in Java or C#. This means it can represent fractional values, but there are some limits to the stored number's magnitude and precision.

What are 64-bit integers?

A 64-bit signed integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). A 64-bit unsigned integer. It has a minimum value of 0 and a maximum value of (2^64)-1 (inclusive).

How do you create a 64-bit integer?

You can declare 8-, 16-, 32-, or 64-bit integer variables by using the __intN type specifier, where N is 8, 16, 32, or 64.


Video Answer


1 Answers

Yes, it is. There's a stage 3 proposal for arbitrary-bigints (including enough to allow implementations to specialize fixed 64-bit use), so it's literally just waiting for implementations and tests at this point. Therefore, one can conclude that it's technically possible.

like image 178
gsnedders Avatar answered Sep 29 '22 02:09

gsnedders