Hi I am trying to understand how write code that deals with large integers greater than the predefined numeric datatypes (ie much greater than 64 bit integers).
I have observed that most libraries actually take a large base $10$ number and treat it as a base $10^9$ number.
For example take the base 10 number : $12345678901234567890123456789012345678901234567890$, if I were to represent this a base $10^9$ number, without introducing any new symbols for the digits (like A or $\alpha$) how would the arithmetic work ?
- Would there be a change in the representation ? I think no, because if each digit is between $0$ and $10^9-1$ then the number should look the same as a base 10 number, provide we are still not using any esoteric symbols to denote the digits. Correct me if I am wrong.
- How would the arithmetic work ? For example how would addition and multiplication work ? How will add and carry work ? Can some simple examples be shared ? I am really confused about how this works.
Of course , the value of the number does not depend on the base $b$ we choose to write it down in a base-$b$-system
Essentially , adding would work blockwise the carry is the sum (+ an eventual carry) modulo $10^9$. Mutltiplication would work analogue to the way it works in base $10$ , but the calculation would become really messy (Basically we would treat the blocks as digits , carries are still taken modulo $10^9$). So, it is better to apply the calculations in base $10$ and transform the result into the base-$10^9$-system which is easy.