Java BigDecimal Divide div(BigDecimal val, long divisor)

Here you can find the source of div(BigDecimal val, long divisor)

Description

div

License

Open Source License

Declaration

public static BigDecimal div(BigDecimal val, long divisor) 

Method Source Code


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

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

public class Main {
    protected static final int PRECISION = 100;

    public static BigDecimal div(long val, long divisor) {
        return div(bd(val), divisor);
    }//from  ww  w. j a v a2 s .c  om

    public static BigDecimal div(BigDecimal val, long divisor) {
        return div(val, bd(divisor));
    }

    public static BigDecimal div(BigDecimal val, BigDecimal divisor) {
        return val.divide(divisor, PRECISION, RoundingMode.HALF_UP);
    }

    public static BigDecimal bd(long val) {
        return BigDecimal.valueOf(val);
    }

    public static BigDecimal bd(double val) {
        return BigDecimal.valueOf(val);
    }
}

Related

  1. decimalDivide(BigDecimal cs, BigDecimal bcs, int scale)
  2. div(BigDecimal b1, BigDecimal b2)
  3. div(BigDecimal d1, BigDecimal d2)
  4. div(BigDecimal v1, BigDecimal v2)
  5. divide(BigDecimal a, BigDecimal b)
  6. divide(BigDecimal amount, BigDecimal divisor)
  7. divide(BigDecimal aValue1, BigDecimal aValue2, int scale)
  8. divide(BigDecimal bd1, BigDecimal bd2)