Home › Forums › C Programming › help › Reply To: help
March 17, 2008 at 2:34 pm
#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:
1 2 3 4 5 6 7 8 9 10 11 12 | int * num;<br /> int * num2;<br /> int * sum;<br /> <br /> initialize ( num , size ); //allocate memory<br /> initialize ( num2 , size ); //allocate memory<br /> <br /> sum = add ( num , num2 ); //sum 2 large numbers<br /> <br /> printf ( "the sum is n" );<br /> printLargeNumber ( sum ); //output sum<br /> |