论坛
Firefox 桌面版
Firefox for Android
附加组件
RSS
搜索
登录
注册
新垣结衣的个人空间
访问量
10
新鲜事
帖子
资料
https://www.firefox.net.cn/index.php?m=space&uid=55997
关于 <input type="number" value="123456789123456789" />
在火狐里看是 123456789123457000 ,有谁知道这个转换的逻辑?
回复
(
10
)
2017-11-16 18:27
来自版块 -
Firefox 正式版和测试版
◆
◆
表情
告诉我的粉丝
提 交
aaaa007cn
:
补上测试用页面 进一步测试后发现输入框的值与 Number.prototype.toLocaleString() 的值类似 都会缩水到 15 位有效数字(即使设置 maximumSignificantDigits 为 21) 设置 toLocaleString 的参数为...
(2017-11-17 11:56)
回复
aaaa007cn
:
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
Let rounded-value be the nu...
(2017-11-16 22:41)
回复
aaaa007cn
:
我错了 之前看岔了 把 123456789123456780 看成 123456789123457000 了 我觉得 firefox 这个应该是 bug
(2017-11-16 22:33)
回复
新垣结衣
:
非常感谢您的回答,受益匪浅。
(2017-11-16 21:17)
回复
新垣结衣
:
非常感谢大家的回答!
(2017-11-16 21:17)
回复
taoww
:
https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number)
“If the element is mutable, the user agent should allow the ...
(2017-11-16 20:48)
回复
新垣结衣
:
所以其它浏览器是作了特殊处理是吗?因为我用了其它浏览器发现是没有舍入。
(2017-11-16 20:11)
回复
taoww
:
很简单。数值是按IEEE-754里规定的binary64这种64位浮点数存储的。能连续精确表示的整数只到2^53=90071992547409922。超过这个上限后,都会按一定规则进行舍入。 反正用这个规范存储数值的软件都会有这个问题,你到google上搜123456789123...
(2017-11-16 20:05)
回复
新垣结衣
:
可是其它浏览器显示的是 123456789123456789 。。包括 EDGE、IE等一众浏览器。
(2017-11-16 19:55)
回复
aaaa007cn
:
temp0.value → "123456789123456789"(字符串) temp0.valueAsNumber → 123456789123456780(数值) 发现了吗? value 还是正确的 问题发生在从字符串转到数值的时候 根本原因在于 ja...
(2017-11-16 19:26)
回复
新垣结衣
加关注
写私信
0
关注
1
粉丝
103
帖子
返回顶部