Java BigInteger Calculate multiply(BigInteger x, BigInteger y)

Here you can find the source of multiply(BigInteger x, BigInteger y)

Description

multiply

License

Open Source License

Declaration

static BigInteger multiply(BigInteger x, BigInteger y) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    static BigInteger multiply(BigInteger x, BigInteger y) {
        final int bitLengthX = x.bitLength();
        final int bitLengthY = y.bitLength();
        if (bitLengthX <= 256 || bitLengthY <= 256 || addInts(bitLengthX, bitLengthY) <= 3600) {
            return x.multiply(y);
        }//w  w  w .j ava 2s.com
        return x.multiply(y);
    }

    public static int addInts(int a, int b) {
        if ((a > 0 && b > Integer.MAX_VALUE - a) || (a < 0 && b < Integer.MIN_VALUE - a)) {
            throw new ArithmeticException("int \"+\" overflow");
        }
        return a + b;
    }
}

Related

  1. modPowByte(byte[] arg, BigInteger e, BigInteger n)
  2. modPowLong(BigInteger n, long exponent, BigInteger modulo)
  3. mods(BigInteger v, BigInteger m)
  4. modulus(BigInteger value, BigInteger divider, int modulo, int... weight)
  5. multi_exponent(BigInteger[] base, BigInteger[] exponent, BigInteger modulus)
  6. negative(BigInteger n)
  7. normalizarParaBigInteger(Number numero, RoundingMode modo)
  8. numberToIpv4(BigInteger ipNumber)
  9. numberToShortString(BigInteger number)