MCPcopy Create free account
hub / github.com/MenoData/Time4J / safeMultiply

Method safeMultiply

base/src/main/java/net/time4j/base/MathUtils.java:255–278  ·  view source on GitHub ↗
(
        int op1,
        int op2
    )

Source from the content-addressed store, hash-verified

253 * @throws ArithmeticException if int-range overflows
254 */
255 public static int safeMultiply(
256 int op1,
257 int op2
258 ) {
259
260 if (op2 == 1) {
261 return op1;
262 }
263
264 long result = ((long) op1) * ((long) op2);
265
266 if ((result < Integer.MIN_VALUE) || (result > Integer.MAX_VALUE)) {
267 StringBuilder sb = new StringBuilder(32);
268 sb.append("Integer overflow: (");
269 sb.append(op1);
270 sb.append(',');
271 sb.append(op2);
272 sb.append(')');
273 throw new ArithmeticException(sb.toString());
274 } else {
275 return (int) result;
276 }
277
278 }
279
280 /**
281 * <p>Multiplies the numbers with range check. </p>

Callers 15

printMethod · 0.95
pushMethod · 0.95
convertMethod · 0.95
betweenMethod · 0.95
fromMethod · 0.95
fromMethod · 0.95
atMethod · 0.95
betweenMethod · 0.95
normalizeMethod · 0.95
convertMethod · 0.95
doAddMethod · 0.95
doAddMethod · 0.95

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected