JAVA计算大整数

public static String bigMulti(String left, String right) 
	{
		char[] lefts = left.toCharArray();
		char[] rights = right.toCharArray();
		int tempLength = lefts.length + rights.length - 1;
		int[] temp = new int[tempLength];
		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 = tempLength - 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 < tempLength; i++) 
		{
			result.append(temp[i]);
		}
		return result.toString();
	}

你可能感兴趣的:(java 大整数)