Java BigDecimal Value Check isDivisible(BigDecimal num1, BigDecimal num2)

Here you can find the source of isDivisible(BigDecimal num1, BigDecimal num2)

Description

is Divisible

License

Apache License

Declaration

public static boolean isDivisible(BigDecimal num1, BigDecimal num2) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {

    public static boolean isDivisible(BigDecimal num1, BigDecimal num2) {
        BigDecimal result = remainder(num1, num2);
        return result.compareTo(BigDecimal.ZERO) == 0 ? true : false;
    }/*from  w ww . j  a  va 2  s .  c  o m*/

    public static BigDecimal remainder(BigDecimal num1, BigDecimal num2) {
        if (null == num2 || BigDecimal.ZERO.compareTo(num2) == 0) {
            return null;
        }
        if (null == num1 || BigDecimal.ZERO.compareTo(num1) == 0) {
            return BigDecimal.ZERO;
        }
        return num1.remainder(num2);
    }
}

Related

  1. isAbsBetweenZeroAndOne(BigDecimal newValue)
  2. isAllBlank(BigDecimal[] values)
  3. isBetweenAAndB(final BigDecimal target, final BigDecimal a, final BigDecimal b)
  4. isBlank(BigDecimal value)
  5. isDouble(BigDecimal number)
  6. isDoubleOverFlow(final BigDecimal decimal)
  7. isExact(final BigDecimal bd)
  8. isFirstBiggerThanSecond(final BigDecimal first, final BigDecimal second)