Java BigDecimal Divide divideBigDecimalsInMap(Map baseMap, BigDecimal divisor)

Here you can find the source of divideBigDecimalsInMap(Map baseMap, BigDecimal divisor)

Description

divide Big Decimals In Map

License

Creative Commons License

Declaration

public static void divideBigDecimalsInMap(Map<String, Object> baseMap, BigDecimal divisor) 

Method Source Code


//package com.java2s;
/*//ww  w . j  a va2 s  . c  om
 * This software is in the public domain under CC0 1.0 Universal plus a
 * Grant of Patent License.
 *
 * To the extent possible under law, the author(s) have dedicated all
 * copyright and related and neighboring rights to this software to the
 * public domain worldwide. This software is distributed without any
 * warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software (see the LICENSE.md file). If not, see
 * <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

import java.math.BigDecimal;

import java.util.*;

public class Main {
    public static void divideBigDecimalsInMap(Map<String, Object> baseMap, BigDecimal divisor) {
        if (baseMap == null || divisor == null || divisor.doubleValue() == 0.0)
            return;
        for (Map.Entry<String, Object> entry : baseMap.entrySet()) {
            if (!(entry.getValue() instanceof BigDecimal))
                continue;
            BigDecimal baseVal = (BigDecimal) entry.getValue();
            entry.setValue(baseVal.divide(divisor, BigDecimal.ROUND_HALF_UP));
        }
    }
}

Related

  1. divide(BigDecimal op1, int op2, int precision)
  2. divide(BigDecimal v1, BigDecimal v2)
  3. divide(final BigDecimal amount, final BigDecimal divideBy, final int scale)
  4. divide(long res, BigDecimal value)
  5. divide(Vector v, BigDecimal magnitude)
  6. divideBy(BigDecimal dividend, BigDecimal divisor)
  7. divideByTwo(BigDecimal number)
  8. divideMoeda(BigDecimal val1, BigDecimal val2)
  9. divideNonZeroValues(BigDecimal operand, BigDecimal divisor)