【发布时间】:2013-08-08 19:15:56
【问题描述】:
我试图返回很长的整数,但我的结果返回为 “7.6561197971049e+016”。 如何让它返回 76561197971049296 ?
local id64 = 76561197960265728
Z = string.match("STEAM_0:0:5391784", 'STEAM_%d+:%d+:(%d+)')
Y = string.match("STEAM_0:0:5391784", 'STEAM_%d+:(%d+):%d+')
--For 64-bit systems
--Let X, Y and Z constants be defined by the SteamID: STEAM_X:Y:Z.
--Let V be SteamID64 identifier of the account type (0x0110000100000000 in hexadecimal format).
--Using the formula W=Z*2+V+Y
if Z == nil then
return "none"
else
return Z*2+id64+Y
end
我现在用这段代码安装了任意精度的 lbc
return bc.add(bc.number(id64),bc.number(2)):tostring()
它返回 70000000000000002 但如果我从 id64 中删除 3 位数字,它会正确显示。
如何在不删除数字的情况下得到正确的结果?
【问题讨论】:
-
非常感谢@lhf 提供了使用单个匹配项提取的提示,并展示了如何将字符串作为字符串传递给 bc。成功了!
-
如果你的长整数适合 64 位,试试我的 lint64,tecgraf.puc-rio.br/~lhf/ftp/lua/#lint64 提供,它比 lbc 更小更简单。
-
是的,我现在正在使用你的 lint64 库,再次感谢。