Big integer, Big float, and operator overloading ideas

Fabrice Bellard fabrice at bellard.org
Mon May 28 11:25:33 UTC 2018


A new revised version of the "BigNum extensions" is available at 
http://numcalc.com/jsbignum.pdf . This new version is 100% compatible 
with standard Javascript with the addition of a "use bigint" mode. It is 
split into 4 proposals:

1) Overloading of the standard operators to support new types such as 
complex numbers, fractions or matrixes.

2) Bigint mode where arbitrarily large integers are available by default 
(no "n" suffix is necessary as in the BigInt proposal at 
https://tc39.github.io/proposal-bigint/ ).

3) Arbitrarily large floating point numbers in base 2 using the IEEE 754 
semantics.

4) Optional "math" mode which modifies the semantics of the division, 
modulo and power operator. The division and power operator return a 
fraction with integer operands and the modulo operator is defined as the 
Euclidian remainder.

A complete demo is available at http://numcalc.com . The command "\mode 
[std|bigint|math]" can be used to switch between the standard javascript 
mode, bigint mode or math mode. In standard Javascript mode, the 
complete TC39 BigInt proposal is supported. In the demo, the default
floating point precision is set to 128 bits. It can be set back to the 
default Javascript precision with "\p f64" or "\p 53 11".

Fabrice.


More information about the es-discuss mailing list