/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }
/** * Returns the precision of this {@code BigDecimal}. The precision is the * number of decimal digits used to represent this decimal. It is equivalent * to the number of digits of the unscaled value. The precision of {@code 0} * is {@code 1} (independent of the scale). * * @return the precision of this {@code BigDecimal}. */ public int precision() { // Return the cached value if we have one. if (precision != 0) { return precision; } if (bitLength == 0) { precision = 1; } else if (bitLength < 64) { precision = decimalDigitsInLong(smallValue); } else { int decimalDigits = 1 + (int) ((bitLength - 1) * LOG10_2); // If after division the number isn't zero, there exists an additional digit if (getUnscaledValue().divide(Multiplication.powerOf10(decimalDigits)).signum() != 0) { decimalDigits++; } precision = decimalDigits; } return precision; }