Takes input BIGs a, b, m and returns a+b modulo m

@param a the first BIG to add
@param b the second BIG to add
@param m the modulus
@return Returns a+b (mod m)
778604
static BIG modAdd(BIG a, BIG b, BIG m) {
        BIG c = a.plus(b);
        c.mod(m);
        return c;
    }
1139149
@Override
    public double compute(double a, double b) {
        return (a * b) / (2 - (a + b - a * b));
    }
1061171
private int modularExponentation(int a, int b, int n) throws IllegalArgumentException {
        int result = 1;
        int counter;
        int maxBinarySize = 32;
        boolean[] b2Binary = new boolean[maxBinarySize];
        for (counter = 0; b > 0; counter++) {
            if (counter >= maxBinarySize){
                throw new IllegalArgumentException("Exponent "+b+" is too big !");
            }
            b2Binary[counter] = (b % 2 != 0);
            b = b / 2;
        }
        for (int k = counter - 1; k >= 0; k--) {
            result = (result * result) % n;
            if (b2Binary[k]){
                result = (result * a) % n;
            }
        }
        return result;
    }
90624
public static long subtractExact(long a, long b) {
        long result = a - b;
        checkNoOverflow((a ^ b) >= 0 | (a ^ result) >= 0);
        return result;
    }
901911
static BigInteger pow5mult(BigInteger b, int k)
    {
        return b.multiply(BigInteger.valueOf(5).pow(k));
    }
1294034
public void mul(IMatrix b, IMatrix result) {
        if ((b == null) || (columns != b.rows)) return;

        if ((result.rows != rows) || (result.columns != b.columns)) result.reshape(rows, b.columns);
        int i, j, k;
        double realsum, imagsum;
        for (i = 0; i < rows; i++)
            for (k = 0; k < b.columns; k++) {
                realsum = 0;
                imagsum = 0;
                for (j = 0; j < columns; j++) {
                    realsum += realmatrix[i][j] * b.realmatrix[j][k] - imagmatrix[i][j] * b.imagmatrix[j][k];
                    imagsum += realmatrix[i][j] * b.imagmatrix[j][k] + imagmatrix[i][j] * b.realmatrix[j][k];
                }
                result.realmatrix[i][k] = realsum;
                result.imagmatrix[i][k] = imagsum;
            }
    }
747566
public Matrix add(Matrix B)
    {
        Matrix toReturn = getThisSideMatrix(B);
        toReturn.mutableAdd(1.0, B);
        return toReturn;
    }
400342
public static boolean cmp(byte[] a, byte[] b) {
		if(a.length != b.length) {
			return false;
		}
		for(int i = 0; i < a.length; i++) {
			if(a[i] != b[i]) {
				return false;
			}
		}
		return true;
	}
1266751
private double mdist(double[] a, double[] b) {
    return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]);
  }
498315
public static BigInteger gcd(BigInteger a, BigInteger b) {
		return gcd(a, b, Calculator.BIG_INTEGER_CALCULATOR);
	}
276066
public static int addExact(int a, int b) {
        long result = (long) a + b;
        checkNoOverflow(result == (int) result);
        return (int) result;
    }
1112010
function mod (a, b, c) {
		binary_arithmetic.call(this, a, b, c, '__mod', mod_internal);
	}
41003
private static double[] plusAndConstMult(double[] a, double[] b, double c,
      double[] d) {
    for (int i = 0; i < a.length; i++) {
      d[i] = a[i] + c * b[i];
    }
    return d;
  }
284886
function multiply(out, a, b) {
  var a00 = a[0],
      a01 = a[1],
      a02 = a[2];
  var a10 = a[3],
      a11 = a[4],
      a12 = a[5];
  var a20 = a[6],
      a21 = a[7],
      a22 = a[8];

  var b00 = b[0],
      b01 = b[1],
      b02 = b[2];
  var b10 = b[3],
      b11 = b[4],
      b12 = b[5];
  var b20 = b[6],
      b21 = b[7],
      b22 = b[8];

  out[0] = b00 * a00 + b01 * a10 + b02 * a20;
  out[1] = b00 * a01 + b01 * a11 + b02 * a21;
  out[2] = b00 * a02 + b01 * a12 + b02 * a22;

  out[3] = b10 * a00 + b11 * a10 + b12 * a20;
  out[4] = b10 * a01 + b11 * a11 + b12 * a21;
  out[5] = b10 * a02 + b11 * a12 + b12 * a22;

  out[6] = b20 * a00 + b21 * a10 + b22 * a20;
  out[7] = b20 * a01 + b21 * a11 + b22 * a21;
  out[8] = b20 * a02 + b21 * a12 + b22 * a22;
  return out;
}
1033279
public static function multiply($a, $b)
    {
        if (function_exists('gmp_mul')) {
            return gmp_mul($a, $b);
        }

        return bcmul($a, $b, 0);
    }
192706
public static function mod(int $a, int $b) : int
    {
        return ($a % $b) + ($a < 0 ? $b : 0);
    }
257056
public static long saturatedMultiply(long a, long b) {
        // see checkedMultiply for explanation
        int leadingZeros = Long.numberOfLeadingZeros(a) + Long.numberOfLeadingZeros(~a) + Long.numberOfLeadingZeros(b) + Long.numberOfLeadingZeros(~b);
        if (leadingZeros > Long.SIZE + 1) {
            return a * b;
        }
        // the return value if we will overflow (which we calculate by overflowing a long :) )
        long limit = Long.MAX_VALUE + ((a ^ b) >>> (Long.SIZE - 1));
        if (leadingZeros < Long.SIZE | (a < 0 & b == Long.MIN_VALUE)) {
            // overflow
            return limit;
        }
        long result = a * b;
        if (a == 0 || result / a == b) {
            return result;
        }
        return limit;
    }