Java BigDecimal Value Check isExact(final BigDecimal bd)

Here you can find the source of isExact(final BigDecimal bd)

Description

is Exact

License

Apache License

Return

true iff the has scale <=0

Declaration

public static boolean isExact(final BigDecimal bd) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    /**/*from   ww w. j  av a2s. c om*/
     * @return {@code true} iff the {@link BigDecimal} has scale {@code <=0}
     * @see <a href="http://stackoverflow.com/a/12748321">stackoverflow
     *      discussion</a>
     */
    public static boolean isExact(final BigDecimal bd) {
        return bd.signum() == 0 || bd.scale() <= 0 || bd.stripTrailingZeros().scale() <= 0;
    }
}

Related

  1. isBetweenAAndB(final BigDecimal target, final BigDecimal a, final BigDecimal b)
  2. isBlank(BigDecimal value)
  3. isDivisible(BigDecimal num1, BigDecimal num2)
  4. isDouble(BigDecimal number)
  5. isDoubleOverFlow(final BigDecimal decimal)
  6. isFirstBiggerThanSecond(final BigDecimal first, final BigDecimal second)
  7. isFirstEqualToSecond(final BigDecimal first, final BigDecimal second)
  8. isJavaMathBigDecimal(Object value)
  9. isLessOrEqualThanZero(BigDecimal value)