1

JavaScript converts all the big numbers into scientific notation. eg: '90938498237058927340892374089' this string when converted to an integer will come out like this scientific notation '9.093849823705893e+28'.

How can I convert the data type from String to an Integer and avoiding the scientific notation?

2 Answers2

2

In JS all the numbers are treated as floating-point so in end, they end up with precision you can use try BigInt('90938498237058927340892374089') which will give you exact number from string to number. apart from this, you can also have a look here Javascript - parse string to long this link might be helpful for you.

Nitesh Sharma
  • 545
  • 3
  • 14
0

Try to use BigInt type:

BigInt('90938498237058927340892374089');

It returns BigInt number with 'n'-literal:

90938498237058927340892374089n
inceptos
  • 1
  • 1