本文整理了Java中java.math.BigDecimal.inplaceRound()
方法的一些代码示例,展示了BigDecimal.inplaceRound()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigDecimal.inplaceRound()
方法的具体详情如下:
包路径:java.math.BigDecimal
类名称:BigDecimal
方法名:inplaceRound
[英]It does all rounding work of the public method round(MathContext), performing an inplace rounding without creating a new object.
[中]它执行公共方法round(MathContext)的所有舍入工作,在不创建新对象的情况下执行就地舍入。
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from the given big integer
* {@code val}. The scale of the result is {@code 0}.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(BigInteger val, MathContext mc) {
this(val);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from a given unscaled value
* {@code unscaledVal} and a given scale. The value of this instance is
* {@code unscaledVal * 10<sup>-scale</sup>). The result is rounded according
* to the specified math context.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
* @throws NullPointerException
* if {@code unscaledVal == null}.
*/
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
this(unscaledVal, scale);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from the given long {@code
* val}. The scale of the result is {@code 0}. The result is rounded
* according to the specified math context.
*
* @param val
* long value to be converted to a {@code BigDecimal} instance.
* @param mc
* rounding mode and precision for the result of this operation.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(long val, MathContext mc) {
this(val);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from the given int {@code
* val}. The scale of the result is {@code 0}. The result is rounded
* according to the specified math context.
*
* @param val
* int value to be converted to a {@code BigDecimal} instance.
* @param mc
* rounding mode and precision for the result of this operation.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code c.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(int val, MathContext mc) {
this(val,0);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from a string representation
* given as a character array. The result is rounded according to the
* specified math context.
*
* @param in
* array of characters containing the string representation of
* this {@code BigDecimal}.
* @param mc
* rounding mode and precision for the result of this operation.
* @throws NumberFormatException
* if {@code in} does not contain a valid string representation
* of a big decimal.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(char[] in, MathContext mc) {
this(in, 0, in.length);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from a string representation
* given as a character array.
*
* @param in
* array of characters containing the string representation of
* this {@code BigDecimal}.
* @param offset
* first index to be copied.
* @param len
* number of characters to be used.
* @param mc
* rounding mode and precision for the result of this operation.
* @throws NumberFormatException
* if {@code offset < 0 || len <= 0 || offset+len-1 < 0 ||
* offset+len-1 >= in.length}, or if {@code in} does not
* contain a valid string representation of a big decimal.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(char[] in, int offset, int len, MathContext mc) {
this(in, offset, len);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from the 64bit double
* {@code val}. The constructed big decimal is equivalent to the given
* double. For example, {@code new BigDecimal(0.1)} is equal to {@code
* 0.1000000000000000055511151231257827021181583404541015625}. This happens
* as {@code 0.1} cannot be represented exactly in binary.
* <p>
* To generate a big decimal instance which is equivalent to {@code 0.1} use
* the {@code BigDecimal(String)} constructor.
*
* @param val
* double value to be converted to a {@code BigDecimal} instance.
* @param mc
* rounding mode and precision for the result of this operation.
* @throws NumberFormatException
* if {@code val} is infinity or not a number.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(double val, MathContext mc) {
this(val);
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Returns a new {@code BigDecimal} whose value is the {@code -this}. The
* result is rounded according to the passed context {@code mc}.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @return {@code -this}
*/
public BigDecimal negate(MathContext mc) {
BigDecimal result = negate();
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: robovm/robovm
/**
* Returns a new {@code BigDecimal} whose value is {@code this *
* multiplicand}. The result is rounded according to the passed context
* {@code mc}.
*
* @param multiplicand
* value to be multiplied with {@code this}.
* @param mc
* rounding mode and precision for the result of this operation.
* @return {@code this * multiplicand}.
* @throws NullPointerException
* if {@code multiplicand == null} or {@code mc == null}.
*/
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) {
BigDecimal result = multiply(multiplicand);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code BigDecimal} instance from a string
* representation. The result is rounded according to the specified math
* context.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @throws NumberFormatException
* if {@code val} does not contain a valid string representation
* of a big decimal.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and the new big decimal cannot be represented
* within the given precision without rounding.
*/
public BigDecimal(String val, MathContext mc) {
this(val.toCharArray(), 0, val.length());
inplaceRound(mc);
}
代码示例来源:origin: robovm/robovm
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: robovm/robovm
/**
* Returns a new {@code BigDecimal} whose value is {@code this}, rounded
* according to the passed context {@code mc}.
* <p>
* If {@code mc.precision = 0}, then no rounding is performed.
* <p>
* If {@code mc.precision > 0} and {@code mc.roundingMode == UNNECESSARY},
* then an {@code ArithmeticException} is thrown if the result cannot be
* represented exactly within the given precision.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @return {@code this} rounded according to the passed context.
* @throws ArithmeticException
* if {@code mc.precision > 0} and {@code mc.roundingMode ==
* UNNECESSARY} and this cannot be represented within the given
* precision.
*/
public BigDecimal round(MathContext mc) {
BigDecimal thisBD = new BigDecimal(getUnscaledValue(), scale);
thisBD.inplaceRound(mc);
return thisBD;
}
代码示例来源:origin: robovm/robovm
accum.inplaceRound(mc);
return accum;
代码示例来源:origin: ibinti/bugvm
/**
* Returns a new {@code BigDecimal} whose value is the {@code -this}. The
* result is rounded according to the passed context {@code mc}.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @return {@code -this}
*/
public BigDecimal negate(MathContext mc) {
BigDecimal result = negate();
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: MobiVM/robovm
/**
* Returns a new {@code BigDecimal} whose value is the {@code -this}. The
* result is rounded according to the passed context {@code mc}.
*
* @param mc
* rounding mode and precision for the result of this operation.
* @return {@code -this}
*/
public BigDecimal negate(MathContext mc) {
BigDecimal result = negate();
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: ibinti/bugvm
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: MobiVM/robovm
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Returns a {@code BigDecimal} whose value is the absolute value of
* {@code this}. The result is rounded according to the passed context
* {@code mc}.
*/
public BigDecimal abs(MathContext mc) {
BigDecimal result = (signum() < 0) ? negate() : new BigDecimal(getUnscaledValue(), scale);
result.inplaceRound(mc);
return result;
}
内容来源于网络,如有侵权,请联系作者删除!