Monday, 26 July 2021

Javascript converts long string into scientific notation, and how to convert scientific string to number

 Javascript converts large number to scientific string

https://stackoverflow.com/questions/1685680/how-to-avoid-scientific-notation-for-large-numbers-in-javascript

JavaScript converts a large INT to scientific notation when the number becomes large. How can I prevent this from happening?




Convert scientific string to number

https://stackoverflow.com/questions/10943997/how-to-convert-a-string-containing-scientific-notation-to-correct-javascript-num

Pass it as a string to the Number function.

Number("4.874915326E7") // returns 48749153.26
Number("4E27") // returns 4e+27

No comments:

Post a Comment