BigDecimal.valueOf

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897674 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-02-01 21:09:43 +00:00
parent 26dc664dfb
commit 47236ba149
2 changed files with 4 additions and 4 deletions

View File

@ -54,8 +54,8 @@ public final class Standardize extends Fixed3ArgFunction implements FreeRefFunct
return ErrorEval.NUM_ERROR;
}
BigDecimal result = new BigDecimal(xval.doubleValue() - mean.doubleValue())
.divide(new BigDecimal(stdev), MathContext.DECIMAL128);
BigDecimal result = BigDecimal.valueOf(xval.doubleValue() - mean.doubleValue())
.divide(BigDecimal.valueOf(stdev), MathContext.DECIMAL128);
return new NumberEval(result.doubleValue());
} catch (EvaluationException e) {
return e.getErrorEval();

View File

@ -107,7 +107,7 @@ public class FractionFormat extends Format {
@SuppressWarnings("squid:S2111")
public String format(Number num) {
final BigDecimal doubleValue = new BigDecimal(num.doubleValue());
final BigDecimal doubleValue = BigDecimal.valueOf(num.doubleValue());
final boolean isNeg = doubleValue.compareTo(BigDecimal.ZERO) < 0;
@ -162,7 +162,7 @@ public class FractionFormat extends Format {
if (wholePartFormatString == null || wholePartFormatString.isEmpty()){
final int fden = fract.getDenominator();
final int fnum = fract.getNumerator();
BigDecimal trueNum = wholePart.multiply(new BigDecimal(fden)).add(new BigDecimal(fnum));
BigDecimal trueNum = wholePart.multiply(BigDecimal.valueOf(fden)).add(BigDecimal.valueOf(fnum));
sb.append(trueNum.toBigInteger()).append("/").append(fden);
return sb.toString();
}