Author: fanningpj
Date: Mon May 23 14:02:47 2022
New Revision: 1901173
URL: http://svn.apache.org/viewvc?rev=1901173&view=rev
Log:
partial implementation FLOOR.MATH function (needs more testing and bad param
support)
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java?rev=1901173&r1=1901172&r2=1901173&view=diff
==============================================================================
---
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java
(original)
+++
poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java
Mon May 23 14:02:47 2022
@@ -62,12 +62,14 @@ public final class FloorMath implements
}
if (roundNegativeNumsDown && xval < 0.0) {
if (multiplier != 1.0) {
- return new NumberEval(scaledRoundUsingBigDecimal(xval,
multiplier, RoundingMode.CEILING));
+ RoundingMode mode = multiplier < 0.0 ? RoundingMode.FLOOR
: RoundingMode.CEILING;
+ return new NumberEval(scaledRoundUsingBigDecimal(xval,
multiplier, mode));
}
return new NumberEval(Math.ceil(xval));
}
if (multiplier != 1.0) {
- return new NumberEval(scaledRoundUsingBigDecimal(xval,
multiplier, RoundingMode.FLOOR));
+ RoundingMode mode = multiplier < 0.0 ? RoundingMode.CEILING :
RoundingMode.FLOOR;
+ return new NumberEval(scaledRoundUsingBigDecimal(xval,
multiplier, mode));
}
return new NumberEval(Math.floor(xval));
} catch (EvaluationException evaluationException) {
Modified:
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java?rev=1901173&r1=1901172&r2=1901173&view=diff
==============================================================================
---
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java
(original)
+++
poi/trunk/poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java
Mon May 23 14:02:47 2022
@@ -47,6 +47,10 @@ final class TestFloorMath {
assertDouble(fe, cell, "FLOOR.MATH(6.7)", 6.0, 0.00000000000001);
assertDouble(fe, cell, "FLOOR.MATH(-8.1,2)", -10.0,
0.00000000000001);
assertDouble(fe, cell, "FLOOR.MATH(-5.5,2,-1)", -4.0,
0.00000000000001);
+
+ assertDouble(fe, cell, "FLOOR.MATH(-2.5,-2)", -4.0,
0.00000000000001);
+ assertDouble(fe, cell, "FLOOR.MATH(-2.5,-2,-1)", -2.0,
0.00000000000001);
+ assertDouble(fe, cell, "FLOOR.MATH(2.5,-2)", 2.0,
0.00000000000001);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]