BigInteger和BigDecimal的用法见http://blog.csdn.net/ly50247/article/details/4361943 以下是关于大整数乘法的具体例子:
public class BigIntMutipli { public static void main(String[] args) { String s1 = new String("1234567898765432100000"); String s2 = new String("1234567899999999999999"); BigInteger bigA = new BigInteger(s1); BigInteger bigB = new BigInteger(s2); System.out.println(s1 + " x " + s2 + " = " + bigA.multiply(bigB)); String d1 = new String("12345678987654.321"); String d2 = new String("123456789999999.9999999"); BigDecimal deciA = new BigDecimal(d1); BigDecimal deciB = new BigDecimal(d2); System.out.println(s1 + " x " + s2 + " = " + deciA.multiply(deciB)); // 将BigInteger的数转为2进制 10代表十进制,2代表2进制 System.out.println(new java.math.BigInteger("123456", 10).toString(2)); } }