Search code examples
javascriptnumberslimit

Is it possible to correctly do math on numbers greater than 2^53?


I am making a calculator in JavaScript that needs to be able to do precise math on numbers larger than 2^53, which is 9007199254740992. Is there any way to do this?


Solution

  • You can use the "strint" library https://github.com/rauschma/strint. For example:

        > var strint = require("./strint");
        > strint.add("9007199254740992", "1")
        '9007199254740993'