How To Handle Very Big Numbers In Node Js?
I am using BigInt(20) datatype for auto Increment id in mysql database. and when the integer value is so big then how can I handle this as after the number precision of javascript,
Solution 1:
You can only pass/show large numbers like that as strings:
varBigNumber = require('big-number');
var x = newBigNumber('999999999999999999999999999999999999999', 10);
console.log(x.toString())
However, in the end, it's up to the MySQL driver how it handles large numbers like this, because it does have to take into account Number.MAX_SAFE_INTEGER
.
For instance, the mysql
module has various options (supportBigNumbers
and bigNumberStrings
) that relate to handling BIGINT
.
Post a Comment for "How To Handle Very Big Numbers In Node Js?"