Javascript无法正确呈现此数字:3494793310847464221 [英] Javascript can't render this number correctly: 3494793310847464221

查看:60
本文介绍了Javascript无法正确呈现此数字:3494793310847464221的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有趣的问题,我一直在用javascript做一些工作,数据库ID出现为3494793310847464221,现在这是作为数字输入javascript但是它使用数字作为不同的值,两者输出到警报时以及传递给另一个javascript函数时。

I have an interesting question, I have been doing some work with javascript and a database ID came out as "3494793310847464221", now this is being entered into javascript as a number yet it is using the number as a different value, both when output to an alert and when being passed to another javascript function.

下面是一些示例代码,可以最大限度地显示错误。

Here is some example code to show the error to its fullest.

<html><head><script language="javascript">alert( 3494793310847464221);
var rar =  3494793310847464221;
alert(rar);
</script></head></html>

这完全阻止了我,因为谷歌不是我的朋友......

This has completly baffeled me and for once google is not my friend...

btw这个数字比那里的数字多179个......

btw the number is 179 more then the number there...

推荐答案

你的号码大于javascript(2 ^ 53)中允许的最大整数值。之前已经涵盖了在不丢失精度的情况下,数字可以达到的JavaScript的最高整数值是多少?

Your number is larger than the maximum allowed integer value in javascript (2^53). This has previously been covered by What is JavaScript's highest integer value that a Number can go to without losing precision?

这篇关于Javascript无法正确呈现此数字:3494793310847464221的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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