Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript large number library? [duplicate]

Tags:

javascript

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.

like image 733
Dmitriy Likhten Avatar asked Nov 12 '09 20:11

Dmitriy Likhten


People also ask

How can you handle a very large number in JavaScript?

To store large numbers in JavaScript, use BigInt() rather than + operator. If you will use the + operator, then expect loss of precision.

How do you round big numbers in JavaScript?

ceil() The Math. ceil() function always rounds a number up to the next largest integer.

What is Bignumber in JavaScript?

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.


1 Answers

As its author, I recommend big.js, 'a small, fast Javascript library for arbitrary-precision arithmetic with decimal numbers'.

like image 58
MikeM Avatar answered Sep 27 '22 20:09

MikeM