mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
partial implementation CEILING.MATH function (needs more testing and bad param support)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901174 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
78ddaabbc2
commit
445b01c04d
@ -62,12 +62,14 @@ public final class CeilingMath implements FreeRefFunction {
|
||||
}
|
||||
if (roundNegativeNumsDown && xval < 0.0) {
|
||||
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));
|
||||
}
|
||||
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));
|
||||
} catch (EvaluationException evaluationException) {
|
||||
|
||||
@ -47,6 +47,11 @@ final class TestCeilingMath {
|
||||
assertDouble(fe, cell, "CEILING.MATH(6.7)", 7.0, 0.00000000000001);
|
||||
assertDouble(fe, cell, "CEILING.MATH(-8.1,2)", -8.0, 0.00000000000001);
|
||||
assertDouble(fe, cell, "CEILING.MATH(-5.5,2,-1)", -6.0, 0.00000000000001);
|
||||
|
||||
assertDouble(fe, cell, "CEILING.MATH(2.5,-2)", 4.0, 0.00000000000001);
|
||||
assertDouble(fe, cell, "CEILING.MATH(-2.5,-2)", -2.0, 0.00000000000001);
|
||||
assertDouble(fe, cell, "CEILING.MATH(-2.5,-2,-1)", -4.0, 0.00000000000001);
|
||||
assertDouble(fe, cell, "CEILING.MATH(0.234, 0.01)", 0.24, 0.00000000000001);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user