PDA

View Full Version : NaNs don't propagate



hcrisp
01-19-2011, 12:26 PM
Discovered in WAVE 9.01f (Windows): Looks like any non-numeric float (whether undefined, infinite, or indeterminate) taken to the power of a zero (either byte, integer, or long, but not float) returns the value of 1.0.



f = machine(/f)
nan = f.nan
inf = 1./0.
ind = sqrt(-1.)
info, nan^0
;<Expression> FLOAT = 1.00000
info, inf^0
;<Expression> FLOAT = 1.00000
info, ind^0
;<Expression> FLOAT = 1.00000

info, nan^0B
;<Expression> FLOAT = 1.00000
info, nan^0L
;<Epression> FLOAT = 1.00000


I can understand why infinity^0 would result in 1, but why aren't the other non-numeric values propagated to the output like they are when you take them to the power of a float zero? It doesn't seem consistent.



info, inf^0.
;<Expression> FLOAT = 1.00000
info, nan^0.
;<Expression> FLOAT = 1.#QNAN
info, ind^0.
;<Expression> FLOAT = -1.#IND0

rwagner
01-24-2011, 01:58 PM
Hi Hcrisp, You are correct, the results seem inconsistent.
This does not happen on unix or win64 (even 9.01f), so it appears to be a win32 issue, maybe caused by the os. All results should really be 1 since sqrt(-1)^0 does really equal 1.

I've filed a change request for this issue and it will be looked at in future releases of PV-WAVE.

-Ryan