Using system;using system.collections.generic;using system.linq;using system.text;namespace BigNumberMultiplication {class Program {static void Main (string[] args) {try {int fir st = 4916; int second = 12345; Long result = First * second; Console.WriteLine (String. Format ("{0} * {1} = {2}\n\n", first. ToString (), second. ToString (), result. ToString ())); String firststr = "100000000000000000000"; String secondstr = "100000000000000000000"; String resultstr = Multipfunction (Firststr, SECONDSTR); Console.WriteLine ("The result is: {0}", Resultstr.trimstart (' 0 ')); Console.WriteLine ("The length of the result is: {0}", Resultstr.trimstart (' 0 '). Length); Console.readkey (); } catch (Exception ex) {}}//Big Data multiplication private static string Multipfunction (Strin G fiRstnumstr, String secondnumstr) {try {int firstnumlength = Firstnumstr.lengt H int secondnumlength = Secondnumstr.length; int resultnumlength = firstnumlength + secondnumlength; int[] Firstnumvalue = new Int[firstnumlength]; int[] Secondnumvalue = new Int[secondnumlength]; int[] Resultnumvalue = new Int[resultnumlength]; Iterates through a string, converting each bit of character into an int shape insert shaping array for the for (int i = 0; i < firstnumlength; i++) { Firstnumvalue[i] = firstnumstr[i]-48; } for (int i = 0; i < secondnumlength; i++) {Secondnumvalue[i] = Seco Ndnumstr[i]-48; }//defined array initialization each bit is 0, so the following procedure can be assigned 0 to omit for (int i = 0; i < resultnumlength; i++) {Resultnumvalue[i] = 0; }//algorithmThe core (the process of the primary written calculation multiplication), multiply the two digits by the bitwise--and the group composition result of the shaping array//Then the result of the shaping array to traverse, the result of the low-order to append to the adjacent high, low-Yu Yu to the low (note: Here said the low is exactly the high point of the array Large bit) for (int i = firstNumLength-1; I >= 0; i--) {for (int j = Seco NdNumLength-1; J >= 0; j--) {resultnumvalue[i + j + 1] + = firstnumvalue[i] * Secondnumvalue[j]; Resultnumvalue[i + j] + = Resultnumvalue[i + J +1]/10; Resultnumvalue[i + j + 1] = resultnumvalue[i + j + 1]% 10; }}//Convert an array into a character array char[] temp = new Char[resultnumlength]; for (int i = 0; i < resultnumlength; i++) {Temp[i] = (char) (Resultnumvalue[i] + 48); }//Converts the character array to string resultstr = new String (temp); return resultstr; } catch (Exception ex) { return string. Empty; } } }}
Multiply Big Data