本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.OVERFLOW属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.OVERFLOW属性的具体用法?Java LocalizedFormats.OVERFLOW怎么用?Java LocalizedFormats.OVERFLOW使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.OVERFLOW属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toIntExact
/** Convert a long to interger, detecting overflows
* @param n number to convert to int
* @return integer with same valie as n if no overflows occur
* @exception MathArithmeticException if n cannot fit into an int
* @since 3.4
*/
public static int toIntExact(final long n) throws MathArithmeticException {
if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE) {
throw new MathArithmeticException(LocalizedFormats.OVERFLOW);
}
return (int) n;
}
示例2: copySign
/**
* Returns the first argument with the sign of the second argument.
*
* @param magnitude Magnitude of the returned value.
* @param sign Sign of the returned value.
* @return a value with magnitude equal to {@code magnitude} and with the
* same sign as the {@code sign} argument.
* @throws MathArithmeticException if {@code magnitude == Byte.MIN_VALUE}
* and {@code sign >= 0}.
*/
public static byte copySign(byte magnitude, byte sign)
throws MathArithmeticException {
if ((magnitude >= 0 && sign >= 0) ||
(magnitude < 0 && sign < 0)) { // Sign is OK.
return magnitude;
} else if (sign >= 0 &&
magnitude == Byte.MIN_VALUE) {
throw new MathArithmeticException(LocalizedFormats.OVERFLOW);
} else {
return (byte) -magnitude; // Flip sign.
}
}
示例3: copySign
/**
* Returns the first argument with the sign of the second argument.
*
* @param magnitude Magnitude of the returned value.
* @param sign Sign of the returned value.
* @return a value with magnitude equal to {@code magnitude} and with the
* same sign as the {@code sign} argument.
* @throws MathArithmeticException if {@code magnitude == Byte.MIN_VALUE}
* and {@code sign >= 0}.
*/
public static byte copySign(byte magnitude, byte sign) {
if ((magnitude >= 0 && sign >= 0) ||
(magnitude < 0 && sign < 0)) { // Sign is OK.
return magnitude;
} else if (sign >= 0 &&
magnitude == Byte.MIN_VALUE) {
throw new MathArithmeticException(LocalizedFormats.OVERFLOW);
} else {
return (byte) -magnitude; // Flip sign.
}
}