Bugzilla 47198 - Fixed formula evaluator comparison of -0.0 and 0.0
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@777392 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
394445888b
commit
bd15957a5b
@ -37,6 +37,7 @@
|
||||
|
||||
<!-- Don't forget to update status.xml too! -->
|
||||
<release version="3.5-beta6" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="add">47198 - Fixed formula evaluator comparison of -0.0 and 0.0</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">47229 - Fixed ExternalNameRecord to handle DDE links</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46287 - Control of header and footer extraction in ExcelExtractor / XSSFExcelExtractor</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46554 - New ant target "jar-examples"</action>
|
||||
|
@ -34,6 +34,7 @@
|
||||
<!-- Don't forget to update changes.xml too! -->
|
||||
<changes>
|
||||
<release version="3.5-beta6" date="2009-??-??">
|
||||
<action dev="POI-DEVELOPERS" type="add">47198 - Fixed formula evaluator comparison of -0.0 and 0.0</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">47229 - Fixed ExternalNameRecord to handle DDE links</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46287 - Control of header and footer extraction in ExcelExtractor / XSSFExcelExtractor</action>
|
||||
<action dev="POI-DEVELOPERS" type="add">46554 - New ant target "jar-examples"</action>
|
||||
|
@ -108,6 +108,10 @@ public abstract class RelationalOperationEval implements OperationEval {
|
||||
if (vb instanceof NumberEval) {
|
||||
NumberEval nA = (NumberEval) va;
|
||||
NumberEval nB = (NumberEval) vb;
|
||||
if (nA.getNumberValue() == nB.getNumberValue()) {
|
||||
// Excel considers -0.0 == 0.0 which is different to Double.compare()
|
||||
return 0;
|
||||
}
|
||||
return Double.compare(nA.getNumberValue(), nB.getNumberValue());
|
||||
}
|
||||
}
|
||||
|
@ -91,4 +91,18 @@ public final class TestEqualEval extends TestCase {
|
||||
BoolEval be = (BoolEval) result;
|
||||
return be.getBooleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel considers -0.0 to be equal to 0.0
|
||||
*/
|
||||
public void testZeroEquality_bug47198() {
|
||||
NumberEval zero = new NumberEval(0.0);
|
||||
NumberEval mZero = (NumberEval) UnaryMinusEval.instance.evaluate(new Eval[] { zero, }, 0,
|
||||
(short) 0);
|
||||
Eval[] args = { zero, mZero, };
|
||||
BoolEval result = (BoolEval) EqualEval.instance.evaluate(args, 0, (short) 0);
|
||||
if (!result.getBooleanValue()) {
|
||||
throw new AssertionFailedError("Identified bug 47198: -0.0 != 0.0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user