Search code examples
windows-7floating-pointfortraninvalidoperationexceptionfloating-point-exceptions

What leads to the floating point exception "1.#IO"


I'm debugging a simulation with many calculations in many Fortran files. I am used to seeing some floating point exceptions (-1.#QNB or 1.#QNAN) for errors that involve division by zero or operations that exceed the maximum size for floating point number. I'm assuming -1.#IO means invalid operation, but I'm not sure mathematically what would cause this and not QNB or QNAN or QINF.

What would lead to the exception -1.#IO?


Solution

  • According to the IEEE 754 Standard for Floating Point Operations, the invalid operation is signaled

    when a NaN or infinite operand cannot be represented in the destination format and this cannot otherwise be indicated [...] When a numeric operand would convert to an integer outside the range of the destination format, the invalid operation exception shall be signaled if this situation cannot otherwise be indicated.

    This page gives a few examples:

    • zero * infinity
    • zero / zero
    • infinity / infinity
    • square root of a negative operand
    • [and a few more]