Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29541 Discussions

Cannot set a complex(8)'s imaginary component to ieee_signaling_nan

WileyOne
New Contributor I
20 Views

Compiler: ifx (IFX) 2026.0.0

OS: Ubuntu 22.04.05 LTS (Jammy Jellyfish)

 

The imaginary part of a complex(8) number cannot successfully be set to ieee_signaling_nan. When displayed, it correct shows "NaN", but when compared using ieee_class to ieee_signaling_nan, it comes up false. Please see the following example; it is also attached.

program main

    use, intrinsic :: ieee_arithmetic

    implicit none
    complex(8) :: c8

    c8 = cmplx(0d0, ieee_value(c8%im,ieee_signaling_nan))

    print *, c8
    print *, c8%im
    print *, ieee_class(c8%im)    == ieee_signaling_nan
    print *, ieee_class(imag(c8)) == ieee_signaling_nan

end program

 

Note that the real part of the complex(8) can be set to ieee_signaling_nan, and the complex(4) case works for real, imaginary, and both.

0 Kudos
0 Replies
Reply