-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigint.h
54 lines (43 loc) · 1018 Bytes
/
bigint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/**
* create a data structure of linked character list
*/
struct char_list {
char num;
struct char_list* next;
};
typedef struct char_list list_t;
typedef list_t* list_ptr;
typedef list_ptr* bigint_t;
/**
* allocate memory to a biginteger initially
* returns a null value
*/
bigint_t allocateBigInt(void);
/**
* print a big integer using recursion
*/
void printBigInt(list_ptr tmp);
/**
* Create a new bigint
* the new integer should store the given int value
* assume that given value is within the range of int
*/
bigint_t new_bigint(int);
/**
* free all the memory used by the given bigint
*/
void free_bigint(bigint_t);
/**
* add bigints a and b and store the results in sum
* Assums: all 3 bigints are allocated before calling
* return 0 if addition was successful
*/
int add(bigint_t sum, bigint_t a, bigint_t b);
/**
* Display the value of the given bigint
*/
void show_bigint(bigint_t);