Java BigDecimal average(BigDecimal... values)

Here you can find the source of average(BigDecimal... values)

Description

average

License

Apache License

Declaration

public static BigDecimal average(BigDecimal... values) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static double average(double... values) {
        double sum = 0;
        for (double val : values) {
            sum += val;
        }//from w w w .j  a v a2 s.  c om
        return sum / values.length;
    }

    public static BigDecimal average(BigDecimal... values) {
        double sum = 0;
        for (BigDecimal val : values) {
            sum += val.doubleValue();
        }
        return new BigDecimal(sum / values.length);
    }
}

Related

  1. adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal)
  2. areEqual(BigDecimal aThis, BigDecimal aThat)
  3. areEqual(BigDecimal first, BigDecimal second)
  4. asArray(final BigDecimal... elements)
  5. average(final BigDecimal... numbers)
  6. bigDecimalListToArray(List list)
  7. bigDecimalObjectValue(Object input)
  8. bigDecimalParse(String value)