Here you can find the source of multiply(BigInteger x, BigInteger y)
static BigInteger multiply(BigInteger x, BigInteger y)
//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; } }