Most languages have functions or libraries that do this, commonly called the Bignum library ( GMP is good.)
If you want to do it yourself, I will do it the same way people do long multiplication on paper. To do this, you can either work with strings containing a number, or do it in binary format using bitwise operations.
Example:
45 x67 --- 315 +270 ---- 585
Or in binary format:
101 x101 ---- 101 000 +101 ------ 11001
Edit: After doing this in binary, I realized that it would be much easier (and rather faster) to encode using bitwise operations instead of strings containing base-10 numbers. I edited my binary multiplication example to show a pattern: for each 1-bit lower number, add the upper number, the bit shifted to the left of the 1-bit time position of the variable. At the end, this variable will contain the product.
To save the product, you will need to have two 64-bit numbers and imagine that one of them is the first 64-bit and the second a second 64-bit product. You will have to write a code that transfers the addition from bit 63 of the second number to bit 0 of the first number.
Jeremy ruten
source share