package com.wr.xml;
public class BigNum {
public static void main(String[] args) {
String s1 = "489464654685789";
String s2 = "46464687837";
System.out.println(mutiply(s1, s2));
}
private static String mutiply(String s1, String s2) {
char[] lefts = s1.toCharArray();
char[] rights = s2.toCharArray();
int length = lefts.length + rights.length - 1;
int[] temp = new int[length];
for (int i = 0; i < lefts.length; i++) {
for (int j = 0; j < rights.length; j++) {
temp[i + j] += Integer.parseInt(String.valueOf(lefts[i]))
* Integer.parseInt(String.valueOf(rights[j]));
}
}
for (int i = length - 1; i >= 0; i--) {
if (temp[i] >= 10 && (i - 1) >= 0) {
temp[i - 1] += temp[i] / 10;
temp[i] = temp[i] % 10;
}
}
StringBuffer result = new StringBuffer();
for (int i = 0; i < length; i++) {
System.out.print(temp[i]);
result.append(temp[i]);
}
System.out.println();
return result.toString();
}
}