0

The issue identified is specific to this number. Also tried ParseInt and ParseFloat and result are same.

convertedNumber:number=0;

this.convertedNumber=Number('17841402576033717');

Output:17841402576033716

1 Answers1

3

You are having issues because your number is bigger than the maximum that can be encoded by a Number, which is 2^53 (Number.MAX_VALUE = 9007199254740991).

You will have to use a library such as BigInt to handle your number.

See the bigint typescript doc.

const big1 = BigInt('17841402576033717');
const big2 = BigInt('17841402576033717');
const big3 = big1 + big2;

console.log(big3.toString());
jo_va
  • 13,504
  • 3
  • 23
  • 47