
From:  Elias Mårtenson 
Subject:  Re: [Bugapl] Equals and notequals operators for complex numbers yield wrong results. 
Date:  Mon, 20 Jan 2014 13:40:55 +0800 
void ComplexCell::bif_equal(Cell * Z, const Cell * A) const{const APL_Float qct = Workspace::get_CT();new (Z) IntCell(equal(*A, qct) ? 1 : 0);}
Gentle people,
In GNU APL 1.0, evaluating
0J0 = 0J0
yields 0. Replacing the equals operator with the notequal operator and
reevaluating yields 1. Furthermore, evaluating
0J0 = 0
yields 0.
I discovered the above anomalies while attempting to write a regression
test for the encode operator. When I attempted to compare the result of
encoding 4 in binary (i.e., 1 0 0) with 1 0 0 and then reducing with
logical and, I get 0. That is because the two zeros in the result are
actually complex zeros and fail to compare for equality with the real
zeros in the expected answer. Oddly enough, the leading 1 does compare
correctly. Maybe the complex 1 demotes to real 1 and then integer 1
correctly while the complex zero does not.
If the above behavior of complex/complex and complex/real compares for
equality/inequality is what is actually intended, the release notes and
user documentation should emphasize the fact.
And if the above has been reported previously, please forgive my
intrusion.
Regards
Fred Pitts
Retired Chemical Engineer
[Prev in Thread]  Current Thread  [Next in Thread] 