You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/22 08:25:58 UTC

svn commit: r777392 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/record/formula/eval/ testcases/org/apache/poi/hssf/record/formula/eval/

Author: josh
Date: Fri May 22 06:25:58 2009
New Revision: 777392

URL: http://svn.apache.org/viewvc?rev=777392&view=rev
Log:
Bugzilla 47198 - Fixed formula evaluator comparison of -0.0 and 0.0

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=777392&r1=777391&r2=777392&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri May 22 06:25:58 2009
@@ -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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=777392&r1=777391&r2=777392&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri May 22 06:25:58 2009
@@ -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>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java?rev=777392&r1=777391&r2=777392&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java Fri May 22 06:25:58 2009
@@ -108,6 +108,10 @@
 			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());
 			}
 		}

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java?rev=777392&r1=777391&r2=777392&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java Fri May 22 06:25:58 2009
@@ -91,4 +91,18 @@
 		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");
+		}
+	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org