It's probably no bug, because maybe some C function does is like that.
But maybe somebody can explain why imag(NaN) == 0
instead of NaN
?
So, then NaN
is only a "real"-Not-a-Number but not a complex one?
PS.
I remember a similar case about sgn(NaN) == 0
.
Examples:
j = {0,1}
c1 = 1 + j*2
c2 = NaN + j*2
c3 = 1 + j*NaN
c4 = NaN + j*NaN
print c1
print c2
print c3
print c4
print ""
print real(c1), imag(c1)
print real(c2), imag(c2)
print real(c3), imag(c3)
print real(c4), imag(c4)
print ""
print real(NaN)
print imag(NaN)
Result:
{1.0, 2.0}
NaN
NaN
NaN
1.0 2.0
NaN 2.0
NaN NaN
NaN NaN
NaN
0.0
Good question.
That is one of a longer list of similar questions I have filed under "decisions to be made before the development version becomes a release candidate"
I had figured to eventually post the list to gnuplot-beta for discussion, but any thoughts you have now are welcome.
I tried to see what C, Fortran, or other languages do with regard to sgn(foo) but did not find any useful guidance. Maybe it's covered in some IEEE standard?