Is there a library available in javascript to handle large numbers with accuracy (sort of like what oracle does by storing the number as a string) and allows for operations like add/subtract/multiply/divide/mod/etc ?
Basically I need to add large numbers like 1234567890.1234567890 + 1234567890.987654321 and get a precise result.
To store large numbers in JavaScript, use BigInt() rather than + operator. If you will use the + operator, then expect loss of precision.
ceil() The Math. ceil() function always rounds a number up to the next largest integer.
A BigInt value, also sometimes just called a BigInt, is a bigint primitive, created by appending n to the end of an integer literal, or by calling the BigInt() function (without the new operator) and giving it an integer value or string value.
As its author, I recommend big.js, 'a small, fast Javascript library for arbitrary-precision arithmetic with decimal numbers'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With