Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In angular 6 i am getting the invalid values when adding the large value numbers.

Is there any solution around this to handle large numbers for addition, comparison, etc?


What I have tried:

9007199254740992==9007199254740993 
o/p = true

9007199254740992+0.98 
o/p = 9007199254740992
Posted
Updated 20-May-19 22:50pm

Numbers in JavaScript cannot be arbitrarily large or precise - numbers are 64-bit values (based on the IEEE 754 standard) and you've hit the limit with your number. You'll have to use an external library such as bignumber.js[^] for arbitrary precision.
 
Share this answer
 
Those are JavaScript 'features'. You may find many workarounds on the web. See, for instance Working with large integers in JavaScript[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900