Home Forums C Programming help Reply To: help

#3359
Humayan
Participant

Usually what is done in this case is one is required to write a large number module for your program. A array of the smallest integer type on your machine is usually used ( a short type or something like that ). You will usually use an array like:
 
short largeNumber [ NUMBER_OF_DIGITS ];
 
and then you will represent large numbers like:
 
12345….
 
largeNumber [ 0 ] = 1

largeNumber [ 1 ] = 2

largeNumber [ 2 ] = 3

largeNumber [ 3 ] = 4

largeNumber [ 4 ] = 5
……..
 
then you write functions to read , write and do mathematical computations on the arrays like:
 

int * num;
int * num2;
int * sum;
 
initialize ( num , size ); //allocate memory
initialize ( num2 , size ); //allocate memory
 
sum = add ( num , num2 ); //sum 2 large numbers
 
printf ( "the sum is n" );
printLargeNumber ( sum ); //output sum