java.math.BigDecimal.decimalDigitsInLong()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中java.math.BigDecimal.decimalDigitsInLong()方法的一些代码示例,展示了BigDecimal.decimalDigitsInLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigDecimal.decimalDigitsInLong()方法的具体详情如下:
包路径:java.math.BigDecimal
类名称:BigDecimal
方法名:decimalDigitsInLong

BigDecimal.decimalDigitsInLong介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * 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;
}

代码示例来源:origin: ibinti/bugvm

/**
 * 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;
}

代码示例来源:origin: MobiVM/robovm

/**
 * 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;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * 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;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * 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;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * 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;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * 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;
}

相关文章

微信公众号

最新文章

更多