lua和javascript之间的不同数字浮点数

lua和javascript之间的不同数字浮点数,lua,precision,floating-accuracy,Lua,Precision,Floating Accuracy,为什么在lua中会出现以下计算 Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > print(6.4620332164+14) 20.4620332164 在使用Javascript时 console.log(6.4620332164+14) VM208:1 20.462033216400002 或者python的 Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:1

为什么在lua中会出现以下计算

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> print(6.4620332164+14)
20.4620332164
在使用Javascript时

console.log(6.4620332164+14)
VM208:1 20.462033216400002
或者python的

Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
>>> print(6.4620332164+14)
20.462033216400002
假设lua浮点数实现都是双精度IEE 754,那么它的特殊之处是什么?

打印对每个参数的字符串调用

> print(20.462033216400002)
20.4620332164
所以,试试看

> print(string.format("%2.15f", 20.462033216400002))
20.462033216400002
只需IEEE-754加倍即可。

打印对每个参数的字符串调用

> print(20.462033216400002)
20.4620332164
所以,试试看

> print(string.format("%2.15f", 20.462033216400002))
20.462033216400002
简单地说,IEEE-754是双倍的