In Lua, what is #INF and #IND?

后端 未结 3 597
庸人自扰
庸人自扰 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 08:00

    #INF is infinite, #IND is NaN. Give it a test:

    print(1/0)
    print(0/0)
    

    Output on my Windows machine:

    1.#INF
    -1.#IND
    

    As there's no standard representation for these in ANSI C, you may get different result. For instance:

    inf
    -nan
    

提交回复
热议问题