Java BigDecimal Value Check isDoubleOverFlow(final BigDecimal decimal)

Here you can find the source of isDoubleOverFlow(final BigDecimal decimal)

Description

is Double Over Flow

License

Apache License

Declaration

public static boolean isDoubleOverFlow(final BigDecimal decimal) 

Method Source Code

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

import java.math.BigDecimal;

public class Main {
    public static final BigDecimal MIN_DOUBLE_POSITIVE = new BigDecimal(
            String.valueOf(Double.MIN_VALUE));
    public static final BigDecimal MAX_DOUBLE_POSITIVE = new BigDecimal(
            String.valueOf(Double.MAX_VALUE));

    public static boolean isDoubleOverFlow(final BigDecimal decimal) {
        if (decimal.signum() == 0) {
            return false;
        }/*from ww  w  .j  a v  a 2  s.c  o m*/

        BigDecimal newDecimal = decimal;
        boolean isPositive = decimal.signum() == 1;
        if (!isPositive) {
            newDecimal = decimal.negate();
        }

        return (newDecimal.compareTo(MIN_DOUBLE_POSITIVE) < 0 || newDecimal
                .compareTo(MAX_DOUBLE_POSITIVE) > 0);
    }
}

Related

  1. isAllBlank(BigDecimal[] values)
  2. isBetweenAAndB(final BigDecimal target, final BigDecimal a, final BigDecimal b)
  3. isBlank(BigDecimal value)
  4. isDivisible(BigDecimal num1, BigDecimal num2)
  5. isDouble(BigDecimal number)
  6. isExact(final BigDecimal bd)
  7. isFirstBiggerThanSecond(final BigDecimal first, final BigDecimal second)
  8. isFirstEqualToSecond(final BigDecimal first, final BigDecimal second)
  9. isJavaMathBigDecimal(Object value)