List of usage examples for java.math BigDecimal multiply
public BigDecimal multiply(BigDecimal multiplicand)
(this × multiplicand)
, and whose scale is (this.scale() + multiplicand.scale()) . From source file:org.apache.calcite.runtime.SqlFunctions.java
/** SQL <code>*</code> operator applied to BigDecimal values. */ public static BigDecimal multiply(BigDecimal b0, BigDecimal b1) { return (b0 == null || b1 == null) ? null : b0.multiply(b1); }
From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java
public BigDecimal updateWithdralFeeAmount(final BigDecimal transactionAmount) { BigDecimal amountPaybale = BigDecimal.ZERO; if (ChargeCalculationType.fromInt(this.chargeCalculation).isFlat()) { amountPaybale = this.amount; } else if (ChargeCalculationType.fromInt(this.chargeCalculation).isPercentageOfAmount()) { amountPaybale = transactionAmount.multiply(this.percentage).divide(BigDecimal.valueOf(100l)); }/* w w w . j a v a 2 s .co m*/ this.amountOutstanding = amountPaybale; return amountPaybale; }
From source file:fsm.series.Series_CC.java
public strictfp double getF2Value(double y, int m, int n) { double Pi = Math.PI; double um = getMu_m(m); double un = getMu_m(n); double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um)); double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un)); double km = um / a; double kn = un / a; BigDecimal Ymd2; BigDecimal Yn;/*from w w w . j a v a 2 s . c om*/ BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y)); BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y)); BigDecimal sin = new BigDecimal(-km * km * sin(km * y)); BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y)); Ymd2 = (cos.add(sin).add(sinh).add(cosh)); BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y)); BigDecimal sinhN = new BigDecimal(-sinh(kn * y)); BigDecimal sinN = new BigDecimal(sin(kn * y)); BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y)); Yn = cosN.add(sinN).add(sinhN).add(coshN); BigDecimal ans = Ymd2.multiply(Yn); return ans.doubleValue(); }
From source file:fsm.series.Series_CC.java
public strictfp double getF5Value(double y, int m, int n) { double um = getMu_m(m); double un = getMu_m(n); double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um)); double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un)); double km = um / a; double kn = un / a; BigDecimal Ymd1; BigDecimal Ynd1;// w ww .j av a 2 s . c om BigDecimal cosh = new BigDecimal(-km * cosh(km * y)); BigDecimal sinh = new BigDecimal(alphaM * km * sinh(km * y)); BigDecimal sin = new BigDecimal(alphaM * km * sin(km * y)); BigDecimal cos = new BigDecimal(km * cos(km * y)); Ymd1 = (cos.add(sin).add(sinh).add(cosh)); BigDecimal coshN = new BigDecimal(-kn * cosh(kn * y)); BigDecimal sinhN = new BigDecimal(alphaN * kn * sinh(kn * y)); BigDecimal sinN = new BigDecimal(alphaN * kn * sin(kn * y)); BigDecimal cosN = new BigDecimal(kn * cos(kn * y)); Ynd1 = cosN.add(sinN).add(sinhN).add(coshN); BigDecimal ans = Ymd1.multiply(Ynd1); return ans.doubleValue(); }
From source file:org.egov.ptis.domain.service.transfer.PropertyTransferService.java
/** * API to calculate mutation fee/*from w w w. j a v a2 s . c o m*/ * * @param partyValue * @param departmentValue * @return MutationFee */ public BigDecimal calculateMutationFee(final BigDecimal partyValue, final BigDecimal departmentValue) { BigDecimal mutationFee = BigDecimal.ZERO; BigDecimal documentValue = partyValue.compareTo(departmentValue) > 0 ? partyValue : departmentValue; if (documentValue.compareTo(BigDecimal.ZERO) > 0) { List<MutationFeeDetails> mutationFeeDetailsList = mutationFeeRepository.getMutationFee(documentValue); if (!mutationFeeDetailsList.isEmpty()) { MutationFeeDetails mutationFeeDetails = mutationFeeDetailsList.get(0); if (mutationFeeDetails != null) { if (mutationFeeDetails.getFlatAmount() != null && mutationFeeDetails.getFlatAmount().compareTo(BigDecimal.ZERO) > 0) if ("N".equalsIgnoreCase(mutationFeeDetails.getIsRecursive().toString())) mutationFee = mutationFeeDetails.getFlatAmount(); else { BigDecimal excessDocValue = documentValue.subtract(mutationFeeDetails.getLowLimit()) .add(BigDecimal.ONE); BigDecimal multiplicationFactor = excessDocValue .divide(mutationFeeDetails.getRecursiveFactor(), BigDecimal.ROUND_CEILING); mutationFee = mutationFeeDetails.getFlatAmount() .add(multiplicationFactor.multiply(mutationFeeDetails.getRecursiveAmount())); } if (mutationFeeDetails.getPercentage() != null && mutationFeeDetails.getPercentage().compareTo(BigDecimal.ZERO) > 0 && mutationFeeDetails.getIsRecursive().toString().equalsIgnoreCase("N")) mutationFee = documentValue.multiply(mutationFeeDetails.getPercentage()) .divide(PropertyTaxConstants.BIGDECIMAL_100); } } } return mutationFee.setScale(0, BigDecimal.ROUND_HALF_UP); }
From source file:com.mbv.web.rest.controller.DeliveryController.java
public Double mul(Integer value1, String value2, Integer scale) { if (scale < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }//from w ww .jav a2 s. c o m BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(value2); return DoubleUtil.round(b1.multiply(b2).doubleValue(), scale); }
From source file:net.shopxx.service.impl.ShippingMethodServiceImpl.java
@Transactional(readOnly = true) public BigDecimal calculateFreight(ShippingMethod shippingMethod, Area area, Integer weight) { Assert.notNull(shippingMethod);/*from w w w .j a va 2s .c o m*/ Setting setting = SystemUtils.getSetting(); BigDecimal firstPrice = shippingMethod.getDefaultFirstPrice(); BigDecimal continuePrice = shippingMethod.getDefaultContinuePrice(); if (area != null && CollectionUtils.isNotEmpty(shippingMethod.getFreightConfigs())) { List<Area> areas = new ArrayList<Area>(); areas.addAll(area.getParents()); areas.add(area); for (int i = areas.size() - 1; i >= 0; i--) { FreightConfig freightConfig = shippingMethod.getFreightConfig(areas.get(i)); if (freightConfig != null) { firstPrice = freightConfig.getFirstPrice(); continuePrice = freightConfig.getContinuePrice(); break; } } } if (weight == null || weight <= shippingMethod.getFirstWeight() || continuePrice.compareTo(BigDecimal.ZERO) == 0) { return setting.setScale(firstPrice); } else { double contiuneWeightCount = Math .ceil((weight - shippingMethod.getFirstWeight()) / (double) shippingMethod.getContinueWeight()); return setting.setScale( firstPrice.add(continuePrice.multiply(new BigDecimal(String.valueOf(contiuneWeightCount))))); } }
From source file:fsm.series.Series_CC.java
public strictfp double getF4Value(double y, int m, int n) { double um = getMu_m(m); double un = getMu_m(n); double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um)); double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un)); double km = um / a; double kn = un / a; BigDecimal Ymd2; BigDecimal Ynd2;/* w w w . j ava 2s .co m*/ BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y)); BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y)); BigDecimal sin = new BigDecimal(-km * km * sin(km * y)); BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y)); Ymd2 = (cos.add(sin).add(sinh).add(cosh)); BigDecimal coshN = new BigDecimal(alphaN * kn * kn * cosh(kn * y)); BigDecimal sinhN = new BigDecimal(-kn * kn * sinh(kn * y)); BigDecimal sinN = new BigDecimal(-kn * kn * sin(kn * y)); BigDecimal cosN = new BigDecimal(alphaN * kn * kn * cos(kn * y)); Ynd2 = cosN.add(sinN).add(sinhN).add(coshN); BigDecimal ans = Ymd2.multiply(Ynd2); return ans.doubleValue(); }
From source file:de.forsthaus.webui.order.OrderPositionDialogCtrl.java
/** * Calculates all necessary values new.//from w w w .j a v a 2s. c o m */ private void doCalculate() { if (!(aupMenge.getValue() == null) && !(aupEinzelwert.getValue() == null)) { if (!aupMenge.getValue().equals(new BigDecimal(0)) && !aupEinzelwert.getValue().equals(new BigDecimal(0))) { BigDecimal count = aupMenge.getValue(); BigDecimal singlePrice = aupEinzelwert.getValue(); BigDecimal amount = count.multiply(singlePrice); aupGesamtwert.setValue(amount); } } }
From source file:org.nd4j.linalg.util.BigDecimalMath.java
/** * Multiply and round./*from w w w . j a v a 2 s .c o m*/ * * @param x The left factor. * @param n The right factor. * @return The product x*n. */ static public BigDecimal multiplyRound(final BigDecimal x, final int n) { BigDecimal resul = x.multiply(new BigDecimal(n)); /* The estimation of the absolute error in the result is |n*err(x)| */ MathContext mc = new MathContext(n != 0 ? x.precision() : 0); return resul.round(mc); }