【问题标题】:In the lua source code, why are they using double and not a more generic lua_Number?在 lua 源代码中,为什么他们使用 double 而不是更通用的 lua_Number?
【发布时间】:2015-09-07 07:51:00
【问题描述】:

在lua源代码中,在文件lobject.h中TValuefields的定义中,为什么d__是double而不是更通用的lua_Number

代码读取

#define TValuefields  \
union { struct { int tt__; Value v__; } i; double d__; } u

不应该吗?

#define TValuefields  \
union { struct { int tt__; Value v__; } i; lua_Number d__; } u

【问题讨论】:

  • 不确定您在看什么...可能是旧版本?最新的 lua (5.2.2) 有 #define TValuefields Value value_; int tt_...
  • 与 5.1.5 相同:#define TValuefields Value value; int tt 和 5.3-work。能澄清一下你指的是Lua版本吗?会不会是 Lua 引擎的轻微修改版?
  • 在 Lua 5.2.2 中,文件后面有#undef TValuefields
  • 我在看 5.2.2。文件中的第二个定义

标签: lua double


【解决方案1】:

TValuefields 的定义仅在LUA_NANTRICK 开启时有效。 NaN 技巧仅适用于 luaconf.h 中提到的双精度数。

【讨论】:

    猜你喜欢
    • 2013-07-10
    • 1970-01-01
    • 2016-08-26
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2011-10-28
    • 2014-07-07
    • 1970-01-01
    相关资源
    最近更新 更多