0-9 only need 4 bits of binary.
The method 1: short is not short, and you can use unsigned char, 1 byte.
Method 2: In order to save more memory, you can use unsigned char to perform bit operation with one high-precision bit every 4 bits.
Method 3: On the basis of method 2, a compressed linked list is established. One node of each linked list stores unsigned characters of fixed length and is compressed before access.
Method 4: Generally, it can't exceed the memory, and the size allowed by the super stack is ok. Using linked list structure alone can solve the problem of super stack.
Method 5: If the 2G memory chip is not enough, then use the external storage algorithm of data structure, which is actually file/database+data structure, only read a part of data at a time, and calculate and store the carry information in most parts.
PS: I don't quite agree with Mo's view that bit operation is complicated. As long as the design framework is reasonable, bit operations can be divided into very safe and simple class libraries.