From 47236ba149952f3b4eb018e19175b3696eb945e5 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Feb 2022 21:09:43 +0000 Subject: [PATCH] BigDecimal.valueOf git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897674 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/ss/formula/functions/Standardize.java | 4 ++-- .../main/java/org/apache/poi/ss/usermodel/FractionFormat.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Standardize.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Standardize.java index 5e34ebf80c..e0cd618ff7 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Standardize.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Standardize.java @@ -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(); diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/FractionFormat.java b/poi/src/main/java/org/apache/poi/ss/usermodel/FractionFormat.java index 71efe9d0e4..0fb2576880 100644 --- a/poi/src/main/java/org/apache/poi/ss/usermodel/FractionFormat.java +++ b/poi/src/main/java/org/apache/poi/ss/usermodel/FractionFormat.java @@ -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(); } -- 2.39.5