}
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) {
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);
}
}