Java BigDecimal Calculate calculatePercentChange(BigDecimal from, BigDecimal to)

Here you can find the source of calculatePercentChange(BigDecimal from, BigDecimal to)

Description

calculate Percent Change

License

Open Source License

Declaration

public static BigDecimal calculatePercentChange(BigDecimal from, BigDecimal to) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    private static final BigDecimal CENT = new BigDecimal(100);

    public static BigDecimal calculatePercentChange(BigDecimal from, BigDecimal to) {
        BigDecimal difference = to.subtract(from);
        return difference.divide(from, 8, RoundingMode.HALF_UP).multiply(CENT);
    }//from ww w .  j  ava2 s .  c  o m
}

Related

  1. calculateDivide(BigDecimal numerator, BigDecimal denominator)
  2. calculateGainPercentage(BigDecimal gain, BigDecimal totalGains)
  3. calculateLHS(BigDecimal a, Vector Bj, Vector Bj1)
  4. calculateMonthCapital(BigDecimal eachIssueMoney, BigDecimal eachMonthInterest)
  5. calculateMonthInterest(Float interestRate, BigDecimal investmoney)
  6. calculateProfit(BigDecimal totalAmt, Integer duration, BigDecimal rate)
  7. calculateRatioInDecimal(BigDecimal numberA, BigDecimal numberB)
  8. coerce(BigDecimal val, int targetPrecision, int targetScale)
  9. cosh(final BigDecimal dec, final int scale, final RoundingMode mode)