admin管理员组文章数量:1398235
When I do the following:
alert((2053716830872415770228778006271971120334843128349550587141047275840274143041).toString());
I get the "2.053716830872415e+75" exponential notation. I want to alert the number as is. I tried toFixed(), toPrecision() and toLocaleString() and they output the same thing.
How can I acplish this? Note: the number is a variable, so I cannot alert("208..");
When I do the following:
alert((2053716830872415770228778006271971120334843128349550587141047275840274143041).toString());
I get the "2.053716830872415e+75" exponential notation. I want to alert the number as is. I tried toFixed(), toPrecision() and toLocaleString() and they output the same thing.
How can I acplish this? Note: the number is a variable, so I cannot alert("208..");
Share Improve this question asked Feb 13, 2011 at 15:55 SuprDewdSuprDewd 2696 silver badges12 bronze badges1 Answer
Reset to default 6Javascript uses 64-bit floating point numbers.
It is impossible to precisely store your value in a Javascript number.
Instead, you should use a BigInteger library.
- http://www.leemon./crypto/BigInt.html
- http://www-cs-students.stanford.edu/~tjw/jsbn/
- https://github./jtobey/javascript-bignum
本文标签: Large numbers to string in JavaScriptStack Overflow
版权声明:本文标题:Large numbers to string in JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744138075a2592490.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论