Js deals with the problem of large numbers

in js, there is a number 12345678901234.123456. The result can only display 12345678901234.123.
is truncated when it is formatted.

""+12345678901234.123456;//12345678901234.123
(12345678901234.123456).toString();//12345678901234.123

I wonder if there is any way to keep this original number? Even if it is converted to a string.

Jul.10,2022

var a = new String ('12345678901234.12345')


(12345678901234.123456)-1234567890123400.123046875
precision has been lost, so don't take it as a digital storage


in the first place.
> Number.isSafeInteger(12345678901234.123456)
> false

this is no longer a safe number for js .

> Number.MAX_SAFE_INTEGER
> 9007199254740991

if it is an integer, you can refer to the number calculation that exceeds the JavaScript safe integer limit-BigInt , but the decimal number may be...


starts with


uses BigNumber to process

Menu