擅长:python、mysql、java
<p>在luaversion5.2之前,Lua<em>number</em>类型使用浮点表示,而Python使用的实际整数只受内存限制。从<a href="http://www.lua.org/manual/5.2/manual.html#2.1" rel="nofollow">Lua 5.2 documentation</a>:</p>
<blockquote>
<p>Number represents real (double-precision floating-point) numbers. </p>
</blockquote>
<p>请注意,数字仍然足够精确,但在显示时是四舍五入的。如果在Python中将结果整数转换为float(它也使用双精度浮点),则可以看到相同的数字:</p>
<pre><code>>>> float(115072593268806)
115072593268806.0
>>> '{:.13e}'.format(float(115072593268806))
'1.1507259326881e+14'
</code></pre>
<p>第二行的格式和Lua一样编号;小数点后有13位数字,使用科学记数法。你知道吗</p>
<p>您可以告诉Lua使用<a href="http://www.lua.org/manual/5.2/manual.html#pdf-string.format" rel="nofollow">^{<cd1>}</a>使用不同的格式打印数字:</p>
<pre><code>print(string.format("%d", mac_int))
</code></pre>
<p>我看到lua5.3<a href="http://www.lua.org/manual/5.3/manual.html#2.1" rel="nofollow">expanded the <em>number</em> type to support 64-bit integers</a>,所以升级到该版本也许可以解决这个问题。你知道吗</p>