src/org/kocakosm/pitaya/math/Numbers.java
public static long safeMultiply(long a, long b)
	{
		if (a == 0L || b == 0L) {
			return 0L;
		}
		long max = a < 0L == b < 0L ? Long.MAX_VALUE : Long.MIN_VALUE;
		if ((b > 0L && b > max / a) || (b < 0L && b < max / a)) {
			throw new ArithmeticException(
				"Long overflow: " + a + " * " + b);
		}
		return a * b;
	}
public static long safeMultiply(long a, long b)
	{
		if (a == 0L || b == 0L) {
			return 0L;
		}
		long max = a < 0L == b < 0L ? Long.MAX_VALUE : Long.MIN_VALUE;
		if ((b > 0L && b > max / a) || (b < 0L && b < max / a)) {
			throw new ArithmeticException(
				"Long overflow: " + a + " * " + b);
		}
		return a * b;
	}
Returns the product of {@code a} and {@code b}, provided the result
fits into a {@code long}.

@param a the first operand.
@param b the second operand.

@return {@code a * b}.

@throws ArithmeticException if {@code a * b} can't be represented by
a {@code long}.