Reputation: 181
I'm printing numbers into a file with Lua, and on occasion instead of a number, -1.#IO will be displayed. What does it mean?
The offending code is in the following gist.
https://gist.github.com/Nelarius/6247636
And the offending number is at the very bottom: meanPrice. The value contained is stored in the Commodity table, and the Commodity table later on logs the value into a file.
Upvotes: 3
Views: 4324
Reputation: 122463
On Windows, the floating point number has output of 1.#INF
for positive infinity and -1.#INF
for negative infinity. The floating point indeterminate number is -1.#IND
. But there's no similar representation of -1.#IO
.
The most probable reason is, you are outputting numbers with a fixed 3 digits of fraction part. And for 3 digits after the decimal point .
, .#INF
or .#IND
get rounded up to .#IO
.
print(-1/0)
print(0/0)
print((string.format("%.3f", -1/0)))
print((string.format("%.3f", 0/0)))
On windows, the output is:
-1.#INF
-1.#IND
-1.#IO
-1.#IO
Upvotes: 6
Reputation: 1017
It is, as the commentors say, an invalid number. It should only appear like this on Windows.
See the link below.
Note, the link refers to (-)1.#IND for NaNs and (-)1.#INF for infinity which I get too. I would be interested in what you're doing to generate the #IO.
IEEE Floating point exceptions
Upvotes: 5