In Lua, what is #INF and #IND?

后端 未结 3 589
庸人自扰
庸人自扰 2021-02-06 07:22

I\'m fairly new to Lua. While testing I discovered #INF/#IND. However, I can\'t find a good reference that explains it.

What are #INF

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 07:50

    Expanding @YuHao already good answer.

    Lua does little when converting a number to a string, since it heavily relies on the underlying C library implementation. In fact Lua print implementation calls Lua tostring which in turn (after a series of other calls) uses the lua_number2str macro, which is defined in terms of C sprintf. Thus in the end you see whatever representation for infinities and NaNs the C implementation uses (this may vary according to which compiler was used to compile Lua and which C runtime your application is linked to).

提交回复
热议问题