-1

/* how can i return the full value not exponential? */

x = 11111111111111111111111112;
y = 23233333333333333333333333;
console.log(x+y);

//how can i return the full value not exponential?
  • Is it just for reading purposes? If so, you can use `(x+y).toLocaleString()` to have a readable number, but the formatting will depend on your locale (it will probably add thousands separators). – kLabz Jan 01 '18 at 15:32
  • 2
    Possible duplicate of [How to avoid scientific notation for large numbers in JavaScript?](https://stackoverflow.com/questions/1685680/how-to-avoid-scientific-notation-for-large-numbers-in-javascript) – jasinth premkumar Jan 01 '18 at 15:33

1 Answers1

1

All the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (the integer 0 has two representations, +0 and −0). That means the valid range for Number is +/- 9007199254740991.

Anything bigger than that range are handled as floating point, in which case it is really difficult to avoid exponent.

let x = 11111111111111111111111112;
let y = 23233333333333333333333333;
console.log(parseFloat(x) + parseFloat(y))
console.log(x+y);

If you want to handle big integers, you can take the help of some library: BigInteger

Mamun
  • 66,969
  • 9
  • 47
  • 59