In Lua, what is #INF and #IND?

Nathan Goings picture Nathan Goings · Oct 1, 2013 · Viewed 7.7k times · Source

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, #IND, and similar (such as negatives) and how do you generate and use them?

Answer

Yu Hao picture Yu Hao · Oct 1, 2013

#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