Note: All code should be written within this template directory. Test cases have been provided in the folder
tests, and can be run usingmake test.
bigint make_bigint(char* str): Parse a string and make it a Big Integer void print_bigint(bigint big_num): Prints the Big Integer bigint int_to_bigint(int num): Creates and sets a bigint to value numbigint init_bigint(): Creates and sets the bigint value to zeroint compare_bigint(bigint a, bigint b): Compares two bigints and returns 0 if equal, +1 if a > b and -1 if a < bbigint zero_adjustment(bigint big_num): Zero justify a number. Makes -0 in the result to +0 if bigint's valuation is zero.bigint shift_by_power_of_10(bigint big_num, int d): Multiply a big int with 10dbigint bigint_add(bigint a, bigint b): Adds two bigints and returns the result (a + b) which is a bigintbigint bigint_sub(bigint a, bigint b): Subtracts two bigints and returns the result (a - b) which is a bigintbigint bigint_mul(bigint a, bigint b): Multiplies two bigints and returns the result (a * b) which is a bigintbigint bigint_div(bigint a, bigint b): Divides two bigints and returns the result (a / b) which is a bigint100 933262154439441526816992388562667004907159682643816214685929638
9521759999322991560894146397615651828625369792082722375825118521091686
4000000000000000000000000 A basic command interface has been written for you in main.c, which allows you to enter commands like set 100000, etc. to set a bigint to 100000. After each command, the result is to be printed. As you implement the above functions, uncomment the corresponding function calls to them (these have been marked with a NOTE), and test them out. Once you are done, remove the debug print statements (also marked with a NOTE).
The following commands are supported by the basic shell,
quit: Leave the command shell. Pressing "Ctrl+D" also quits the command shell. set x: Sets a bigint to x and prints itadd x y: Adds 'x' and 'y' and prints the resultant bigint. sub x y: Subtracts 'x' and 'y' and prints the resultant bigint. mul x y: Multiplies 'x' and 'y' and prints the resultant bigint. div x y: Divides 'x' and 'y' and prints the resultant bigint.