0

I periodically get extraneous results when I run a program I have constructed. Instead of printing a float, I get this: -1.#IO. What does this result indicate? A divide by zero?

In my experience, if the result was an overflow then it should still print correctly, just a an incorrect value (perhaps some large negative).

Here is what I am getting most of the time:

enter image description here

Here is what happens about every 6-7 runs.

enter image description here

If I run the program using a constant seed (assuming that seed produces correct results), then everything works fine indefinitely. However, if I run using a random seed, like time(0), I tend to see this program explode at run-time.

In short, has anyone experienced this result before? Just looking for a starting point to dive into the code.

6
  • 1
    Which compiler/libc are you using? Commented Feb 25, 2014 at 5:24
  • Actually, I didn't think about that. I am using a C89 compiler included with Visual Studio 2012. I migrated to writing C programs in the IDE and was told that it does VS does not support a C99 compiler. Perhaps this is the issue. The only libraries I am using are the ANSI C ones (like stdio, stlid, time, math, etc). Commented Feb 25, 2014 at 5:29
  • Worked fine using C99 compiler. I dare not even ask what could have caused this using a C89 compiler. It could have been anything. Commented Feb 25, 2014 at 5:35
  • What is the format string you're using? Looks like some fixed decimal format that may not fit inside the fixed character restrictions. Commented Feb 25, 2014 at 5:40
  • You got this special output maybe because your compiler/libc wants to inform you that some error happened, and this specific output may depend on the specific compiler/libc you are using. Commented Feb 25, 2014 at 5:44

1 Answer 1

3

On Windows, infinity is printed as 1.#INF. A quirk in the standard library means that rounding it to three decimal places gives 1.#IO ('F' >= '5', so it increments the 'N').

For the same reason, -1.#IO is negative infinity.

And yes, you could get this result by dividing by zero.

Sign up to request clarification or add additional context in comments.

1 Comment

Or, another possibility is -1.IND for values like 0/0.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.