Changed the Complex.equals() method so that it considers +0 and -0 are equal,

as required by IEEE-754 standard.
JIRA: MATH-221

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@690308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-08-29 15:46:22 +00:00
parent a48a97b37f
commit 94cf29c4e3
3 changed files with 11 additions and 4 deletions

View File

@ -255,10 +255,7 @@ public class Complex implements Serializable {
if (rhs.isNaN()) {
ret = this.isNaN();
} else {
ret = (Double.doubleToRawLongBits(real) ==
Double.doubleToRawLongBits(rhs.getReal())) &&
(Double.doubleToRawLongBits(imaginary) ==
Double.doubleToRawLongBits(rhs.getImaginary()));
ret = (real == rhs.real) && (imaginary == rhs.imaginary);
}
} catch (ClassCastException ex) {
// ignore exception

View File

@ -39,6 +39,10 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="2.0" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="MATH-221" due-to="Dieter Roth">
Changed the Complex.equals() method so that it considers +0 and -0 are equal,
as required by IEEE-754 standard.
</action>
<action dev="luc" type="add" issue="MATH-220" >
Added JAMA-like interfaces for decomposition algorithms. These interfaces
decompose a matrix as a product of several other matrices with predefined

View File

@ -690,4 +690,10 @@ public class ComplexTest extends TestCase {
public void testTanhCritical() {
TestUtils.assertSame(nanInf, new Complex(0, pi/2).tanh());
}
/** test issue MATH-221 */
public void testMath221() {
assertEquals(new Complex(0,-1), new Complex(0,1).multiply(new Complex(-1,0)));
}
}