Package java.math

Examples of java.math.BigDecimal.precision()


    }
    else {
      bigNum = new BigDecimal( num.toString() );
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here


    BigDecimal bigNum = getBigDecimalValue( str );
    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here

            type = MApproximateNumber.FLOAT.instance(false);
            value = new Value(type, (Float)object);
        }
        else if (object instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) object;
            int precision = bd.precision();
            int scale = bd.scale();
            if (precision < scale) {
                // BigDecimal interprets something like "0.01" as having a scale of 2 and precision of 1.
                precision = scale;
            }
View Full Code Here

    Decimal28SparseHolder dch = new Decimal28SparseHolder();

    BigDecimal bigDecimal = new BigDecimal(decimal);

    dch.scale = bigDecimal.scale();
    dch.precision = bigDecimal.precision();
    Decimal28SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
    dch.start = 0;
    dch.buffer = buf.reallocIfNeeded(5 * DecimalUtility.integerSize);
    DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);

View Full Code Here

      Decimal38SparseHolder dch = new Decimal38SparseHolder();

      BigDecimal bigDecimal = new BigDecimal(decimal);

      dch.scale = bigDecimal.scale();
      dch.precision = bigDecimal.precision();
      Decimal38SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
      dch.start = 0;
      dch.buffer = buf.reallocIfNeeded(dch.maxPrecision * DecimalUtility.integerSize);
      DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);

View Full Code Here

    }
    else {
      bigNum = new BigDecimal( num.toString() ).stripTrailingZeros();
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here

    BigDecimal bigNum = getBigDecimalValue( charSequence );
    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here

        if ((this.precision() - this.scale) <= 0) {
            throw new ArithmeticException("Rounding necessary");
        }
        // round to an integer, with Exception if decimal part non-0
        BigDecimal num = setScale(0, RoundingMode.UNNECESSARY);
        if (num.precision() >= 19) {
            LongOverflow.check(num);
        }
        return $(num).inflated().longValue();
    }
View Full Code Here

    BigDecimal s;

    s = new BigDecimal(m.unscaledValue(), 0);

    // 10**k is the greatest power of 10 <= s, i.e. k = floor(log10(s))
    k = s.precision() - s.scale();

    // (1) s     = m * 10**m.scale()   by def of BigDecimal.unscaledValue()
    // (2) m     = s * 10**(n-k)       by def of s,n,k
    // (3) m     = s * 10**-m.scale()  from 1
    // (4) n - k = -m.scale()          by 2, 3
View Full Code Here

    BigDecimal bigNum = getBigDecimalValue( str );
    if ( bigNum == null ) {
      return false;
    }

    int integerPartLength = bigNum.precision() - bigNum.scale();
    int fractionPartLength = bigNum.scale() < 0 ? 0 : bigNum.scale();

    return ( maxIntegerLength >= integerPartLength && maxFractionLength >= fractionPartLength );
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.