This is a homework question. In SML, there's a limit to integer size that is Int.maxInt, so I have to design a package that can represent large integers as well as perform operations such as add, multiplication etc. Now, the obvious choice is to split up into a list or array where each element has an integer of acceptable size. But if define a function suppose,
IntToLargeInt(x, base) = (x mod base) :: IntToLargeInt(x div base , base)
Now, for integers less than the max size, it does convert to a number of another base in a list. But with large integers, before it can even split it up, it raises overflow exception. So, any hint to how to parse from the function argument directly like a stdin stream or something like that. Basically, anything to help me make the function work for large integers.
Should I use types such as IntInf to store it first and then convert to another base?
Or perhaps if i'm going in the wrong direction, some hints about where to start would be good.