how to handle big numbers greater than 10^18 in c????

, ,

plz tell me how to handle big numbers in C when we have to perform the following operations:
multiply,divide,modulo,subtraction…problem link

1 Like

You can store them in array. Digit after digit. The best way is remembered last digit of number on 0-th position and so on. For example number 5103 is in array A remembered as A[0]=3, A[1]=0, A[2]=1 and A[3]=5. With this representation is easy to add two such numbers, add to this number classic iteger, multiply or division by integer.

Harder is to multiply two such numbers, or divide them.

The main idea is to store them as integer arrays.addition and subtraction is straight forward.multiplication and division is slightly more complex. Please read this awesome tutorial by @kuruma for more information.