Details
Description
Two complex numbers with real/imaginary parts 0.0d but different signs compare as equal numbers. This is according to their mathematical value; the comparison is done via
return (real == c.real) && (imaginary == c.imaginary);
Unfortunately, two Double values do NOT compare as equal in that case, so real.equals(c.real) would return false if the signs differ.
This becomes a problem because for the hashCode, MathUtils.hash is used on the real and imaginary parts, which in turn uses Double.hash.
This violates the contract on equals/hashCode, so Complex numbers cannot be used in a hashtable or similar data structure:
Complex c1 = new Complex(0.0, 0.0);
Complex c2 = new Complex(0.0, 0.0);
// Checks the contract: equalshashcode on c1 and c2
assertTrue("Contract failed: equalshashcode on c1 and c2", c1.equals(c2) ? c1.hashCode() == c2.hashCode() : true);
Activity
Field  Original Value  New Value 

Attachment  Report5.java [ 12640028 ] 
Attachment  Report5a.java [ 12640036 ] 
Attachment  MATH1118.patch [ 12640066 ] 
Attachment  MATH1118.patch [ 12640615 ] 
Status  Open [ 1 ]  Resolved [ 5 ] 
Fix Version/s  3.3 [ 12324600 ]  
Resolution  Fixed [ 1 ] 
Status  Resolved [ 5 ]  Closed [ 6 ] 
Resolution  Fixed [ 1 ]  
Status  Closed [ 6 ]  Reopened [ 4 ] 
Status  Reopened [ 4 ]  Resolved [ 5 ] 
Fix Version/s  4.0 [ 12317577 ]  
Fix Version/s  3.6 [ 12332157 ]  
Fix Version/s  3.3 [ 12324600 ]  
Resolution  Fixed [ 1 ] 
Status  Resolved [ 5 ]  Closed [ 6 ] 
Transition  Time In Source Status  Execution Times  Last Executer  Last Execution Date  


4d 9h 56m  1  Gilles  18/Apr/14 16:00  

352d 15h 21m  1  Cyrille Artho  07/May/15 06:35  

8h 12m  1  Luc Maisonobe  07/May/15 14:47  

294d 4h 52m  2  Luc Maisonobe  25/Jan/16 20:28 
Dfp instances are affected in the same way (0.0 == 0.0 but their hash code differs).