[removed] how to avoid scientific notation when displaying large unumber

后端 未结 2 1419
感动是毒
感动是毒 2021-01-20 08:27

Based on http://users.dickinson.edu/~braught/courses/cs131s99/Lessons/03-Out&Data.html, for readability, JavaScript uses scientific notation to display very large number

相关标签:
2条回答
  • 2021-01-20 08:53

    You can use something like YourJS.fullNumber(). For instance you could try something like YourJS.fullNumber(1e20) to produce 100000000000000000000. Try out your own code here:

    https://www.yourjs.com/console/?gist=9dce161c033e7391b2f871a19006a653&file=Example+of+YourJS.fullNumber.js

    0 讨论(0)
  • 2021-01-20 09:14

    It’s not for readability. If an integer is larger than 253 (9007199254740992), then JavaScript cannot guarantee its exact storage. In your case the number is actually 999999999999999983222784.

    0 讨论(0)
提交回复
热议问题