NaN issue in fortran 90
问题 I realize that if you write Real (Kind(0.d0))::x,y x = sqrt(-1.d0) y = sqrt(-1.d0) if (x == y) then write(*,*)'yep, they are equals', x endif It compiles ok using ifort. But nothing is written, the conditional is always false , did you notice that? why is this so? 回答1: NaN signifies not a number, and since there are many, different, reasons a calculation could give that result, they generally do not compare as equal against themselves. If you want to do nan-testing, fortran compilers that