Returns the product of {@code a} and {@code b}, provided it does not overflow.

@throws ArithmeticException if {@code a * b} overflows in signed {@code int} arithmetic
19623
public static int checkedMultiply(int a, int b) {
    long result = (long) a * b;
    checkNoOverflow(result == (int) result);
    return (int) result;
  }
1012828
public IntLongSortedVector getProd(IntLongVector other) {
        IntLongSortedVector prod = new IntLongSortedVector(this);
        prod.product(other);
        return prod;
    }
1004535
public static int addExact(int x, int y) {
        int r = x + y;
        // HD 2-12 Overflow iff both arguments have the opposite sign of the result
        if (((x ^ r) & (y ^ r)) < 0) {
            throw new ArithmeticException("integer overflow");
        }
        return r;
    }
168242
@javax.annotation.Nonnull
  public static double[] op(@javax.annotation.Nonnull final double[] a, @javax.annotation.Nonnull final double[] b, @javax.annotation.Nonnull final DoubleBinaryOperator fn) {
    assert a.length == b.length;
    @javax.annotation.Nonnull final double[] c = new double[a.length];
    for (int j = 0; j < a.length; j++) {
      c[j] = fn.applyAsDouble(a[j], b[j]);
    }
    return c;
  }
1103515
public PackedDecimal multiply(Bruch operand) {
        AbstractNumber produkt = toBruch().multiply(operand);
        return PackedDecimal.valueOf(produkt);
    }
1139149
@Override
    public double compute(double a, double b) {
        return (a * b) / (2 - (a + b - a * b));
    }
577882
@Inline(value="$1.add($2)")
	@Pure
	public static BigInteger operator_plus(BigInteger a, BigInteger b) {
		return a.add(b);
	}
1077901
public void product(IntDoubleVector other) {
        // TODO: Add special case for IntDoubleDenseVector.
        for (int i=0; i<size; i++) {
            elements[i + start] *= other.get(i);
        }
    }
506622
public BigInteger getAndIncrement() {
        while (true) {
        	BigInteger current = get();
        	BigInteger next = current.add(BigInteger.ONE);
            if (compareAndSet(current, next))
                return current;
        }
    }
763547
public <T extends Average> T merge(T other) {
        if(Util.productGreaterThan(count, (long)Math.ceil(avg), Long.MAX_VALUE) ||
          Util.productGreaterThan(other.count(), (long)Math.ceil(other.average()), Long.MAX_VALUE)) {
            // the above computation is not correct as the sum of the 2 products can still lead to overflow
            // a non-weighted avg
            avg=avg + other.average() / 2.0;
        }
        else { // compute the new average weighted by count
            long total_count=count + other.count();
            avg=(count * avg + other.count() * other.average()) / total_count;
            count=total_count/2;
        }
        return (T)this;
    }
1212005
public IntFloatSortedVector getSum(IntFloatVector other) {
        IntFloatSortedVector sum = new IntFloatSortedVector(this);
        sum.add(other);
        return sum;
    }
1119184
@Override
  public UnionWeight<W> plus(UnionWeight<W> a, UnionWeight<W> b) {
    if (isZero(a)) return b;
    if (isZero(b)) return a;

    ImmutableList.Builder<W> builder = ImmutableList.builder();
    int cursorA = 0;
    int cursorB = 0;

    while (cursorA < a.size() && cursorB < b.size()) {
      W nextA = a.get(cursorA);
      W nextB = b.get(cursorB);

      int compare = ordering.compare(nextA, nextB);
      if (compare < 0) {
        builder.add(nextA);
        cursorA += 1;
      } else if (compare > 0) {
        builder.add(nextB);
        cursorB += 1;
      } else {
        // compare == 0, they are equal, then merge; because a and b are legal UnionWeights already we know they
        // don't have any duplicates so we can increment both
        builder.add(mergeStrategy.merge(nextA, nextB));
        cursorA += 1;
        cursorB += 1;
      }
    }
    for (; cursorA < a.size(); cursorA++) {
      builder.add(a.get(cursorA));
    }
    for (; cursorB < b.size(); cursorB++) {
      builder.add(b.get(cursorB));
    }
    return makeCheckedFrom(builder.build());
  }
1367356
@Override
  public Double product11(Double arg1, Double arg2) {
    if (arg1 == null || arg2 == null) {
      return Double.NaN;
    } else {
      return arg1 * arg2;
    }
  }
1283670
@Pure
	public static double operator_power(Double a, Number b) {
		return Math.pow(a, b.doubleValue());
	}
254308
private static int subAndCheck(final int x, final int y) {
        final long s = (long) x - (long) y;
        if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
            throw new ArithmeticException("overflow: add");
        }
        return (int) s;
    }
586117
public static int sum(int[] x) {
        double sum = 0.0;

        for (int n : x) {
            sum += n;
        }

        if (sum > Integer.MAX_VALUE || sum < -Integer.MAX_VALUE) {
            throw new ArithmeticException("Sum overflow: " + sum);
        }
        
        return (int) sum;
    }
1142255
public static int safeMultiply(int a, int b) {
        long total = (long) a * (long) b;
        if (total < Integer.MIN_VALUE || total > Integer.MAX_VALUE) {
            throw new ArithmeticException("Multiplication overflows an int: " + a + " * " + b);
        }
        return (int) total;
    }