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

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

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

BigDecimal.valueExact介绍

[英]If intVal has a fractional part throws an exception, otherwise it counts the number of bits of value and checks if it's out of the range of the primitive type. If the number fits in the primitive type returns this number as long, otherwise throws an exception.
[中]如果intVal有一个小数部分,则抛出异常,否则它将计算值的位数并检查它是否超出原语类型的范围。如果该数字与基元类型匹配,则返回该数字,否则抛出异常。

代码示例

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a short value if it has no fractional
 * part and if its value fits to the short range ([-2<sup>15</sup>..2<sup>15</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary of the number doesn't fit in a short.
 */
public short shortValueExact() {
  return (short) valueExact(16);
}

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

/**
 * Returns this {@code BigDecimal} as a byte value if it has no fractional
 * part and if its value fits to the byte range ([-128..127]). If these
 * conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a byte.
 */
public byte byteValueExact() {
  return (byte) valueExact(8);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a short value if it has no fractional
 * part and if its value fits to the short range ([-2<sup>15</sup>..2<sup>15</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary of the number doesn't fit in a short.
 */
public short shortValueExact() {
  return (short) valueExact(16);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a short value if it has no fractional
 * part and if its value fits to the short range ([-2<sup>15</sup>..2<sup>15</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary of the number doesn't fit in a short.
 */
public short shortValueExact() {
  return (short) valueExact(16);
}

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

/**
 * Returns this {@code BigDecimal} as a byte value if it has no fractional
 * part and if its value fits to the byte range ([-128..127]). If these
 * conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a byte.
 */
public byte byteValueExact() {
  return (byte) valueExact(8);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a short value if it has no fractional
 * part and if its value fits to the short range ([-2<sup>15</sup>..2<sup>15</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary of the number doesn't fit in a short.
 */
public short shortValueExact() {
  return (short) valueExact(16);
}

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a long value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>63</sup>..2<sup>63</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a long.
 */
public long longValueExact() {
  return valueExact(64);
}

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

/**
 * Returns this {@code BigDecimal} as a byte value if it has no fractional
 * part and if its value fits to the byte range ([-128..127]). If these
 * conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in a byte.
 */
public byte byteValueExact() {
  return (byte) valueExact(8);
}

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

/**
 * Returns this {@code BigDecimal} as a int value if it has no fractional
 * part and if its value fits to the int range ([-2<sup>31</sup>..2<sup>31</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary or the number doesn't fit in an int.
 */
public int intValueExact() {
  return (int) valueExact(32);
}

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

/**
 * Returns this {@code BigDecimal} as a short value if it has no fractional
 * part and if its value fits to the short range ([-2<sup>15</sup>..2<sup>15</sup>-1]). If
 * these conditions are not met, an {@code ArithmeticException} is thrown.
 *
 * @throws ArithmeticException
 *             if rounding is necessary of the number doesn't fit in a short.
 */
public short shortValueExact() {
  return (short) valueExact(16);
}

相关文章

微信公众号

最新文章

更多