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

sqrt(NaN)

tropfen
New Contributor I
575 Views
Hello,

looking inside old threads if have found many comments on how to produce a NaN using sqrt().

I have a question about what should happen based on fortran standard with

sqrt(NaN)

In CVF 6.6 it is an error. In IVF 10.1.026 it is no error.

Thanks in advance.

Frank
0 Kudos
3 Replies
Steven_L_Intel1
Employee
575 Views
The Fortran standard does not define the result. With IVF, I would expect that you get a NaN result. A run-time error might occur if you used /fpe:0.
0 Kudos
tropfen
New Contributor I
575 Views
The Fortran standard does not define the result. With IVF, I would expect that you get a NaN result. A run-time error might occur if you used /fpe:0.

Hello,

to be honest, I was afraid to get this kind of answer. In the last weeks and months i had to read quite often a reply like: you have to set this /xxx: yyyy.

For me sending a NaN into a call like sqrt has to produce an error in the standard configuration of IVF. Sending in an NaN and getting back a NaN is not normal behavior.

May be I have lost contact to modern programming.

Frank
0 Kudos
Steven_L_Intel1
Employee
575 Views
The normal behavior for operations on NaNs in IEE floating point is to result in a NaN.
0 Kudos
Reply