如何在Javascript中显示大整数? [英] How to display large integers in Javascript?

查看:87
本文介绍了如何在Javascript中显示大整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Javascript中显示大整数?



取其显示为2.344444555e + 3455。它没有正确显示。使用字符和数字没有问题。

解决方案

JavaScript不支持如此大的整数。如果你在JavaScript中输入这样的文字,它将被解析为无限。



可能的解决方案之一就是使用BigInteger库来实现JavaScript 。例如,考虑一下: http://silentmatt.com/biginteger [ ^ ]。



参见: http://www.leemon.com/crypto/BigInt.html [ ^ ]。



-SA

How to display large integers in Javascript?

On fetching its displayed as 2.344444555e+3455. Its not displayed properly. With characters and numbers there is no issue.

解决方案

JavaScript does not support so big integers. If you enter the assignment to such literal in JavaScript, it will be parsed to Infinity.

One of the possible work-around solution would be using a BigInteger library for JavaScript. Consider, for example, this: http://silentmatt.com/biginteger[^].

See also: http://www.leemon.com/crypto/BigInt.html[^].

—SA


这篇关于如何在Javascript中显示大整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆