-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbigInteger.h
More file actions
211 lines (187 loc) · 4.66 KB
/
bigInteger.h
File metadata and controls
211 lines (187 loc) · 4.66 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
* Prototype of bigIntegers functions
* By Isaac Chiboub - isaac.chiboub@utbm.fr
* And Thibault Miclo - thibault.miclo@utbm.fr
*
* Last edit : 23/12/11
*/
typedef struct {
Boolean sign;
Dlist absvalue;
} nb; /* bigInteger Structure */
typedef nb* bigInteger; /* Define a bigInteger */
/*
* newBigInteger - make a bigInteger with user input
* Arguments
* - char nb[] - An array of char, inputed by the user
*
* Return : bigInteger, a pointer on the newly created bigInteger
*
*/
bigInteger newBigInteger(char nb[]);
/*
* inputToValidNb - Replace wrong caracters by 0
* Arguments :
* - int a - A char
*
* Return : Ascii value of 0 is the char is wrong
* else return a
*
*/
int inputToValidNb(int a);
/*
* sumBigInt - computes the sum between a bigInteger A and a bigInteger B
* Arguments
* - bigInteger A - One of the bigIntegers
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the sum
*
*/
bigInteger sumBigInt(bigInteger a, bigInteger b);
/*
* diffBigInt - computes the diff between a bigInteger A and a bigInteger B
* Arguments
* - bigInteger A - One of the bigIntegers
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the diff
*
*/
bigInteger diffBigInt(bigInteger a, bigInteger b);
/*
* sumBigInt - computes the multiplication between a bigInteger A and a bigInteger B
* Arguments
* - bigInteger A - One of the bigIntegers
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the multiplication
*
*/
bigInteger mulBigInt(bigInteger a, bigInteger b);
/*
* sumBigInt - computes the quotient of bigInteger A / bigInteger B
* Arguments
* - bigInteger A - The divided bigInteger
* - bigInteger B - The divisor bigInteger
*
* Return : bigInteger, a pointer on the result bigInteger, the quotient
*
*/
bigInteger quotientBigInt(bigInteger a, bigInteger b);
/*
* getNumberN - useful for quotientBigInt, to go down the number N at each step
* Arguments
* - bigInteger A - bigInteger where we seek the number
* - int n - position of the number in the bigInteger
*
* Return : Return the n-number of bigInteger A
*
*/
int getNumberN(bigInteger a,int n);
/*
* restBigInt - compute the rest of the division : bigInteger A / bigInteger B
* Arguments
* - bigInteger A - The divided bigInteger
* - bigInteger B - The divisor bigInteger
*
* Return : bigInteger, a pointer on the result bigInteger, the rest
*
*/
bigInteger restBigInt(bigInteger a, bigInteger b);
/*
* restBigInt - compute the greatest commom divisior of two bigIntegers A and B : gcd(A,B)
* Arguments
* - bigInteger A - The first bigInteger
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the gcd
*
*/
bigInteger gcdBigInt(bigInteger a, bigInteger b);
/*
* restBigInt - compute the lowest common multiple of two bigIntegers A and B : lcm(A,B)
* Arguments
* - bigInteger A - The first bigInteger
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the rest
*
*/
bigInteger lcmBigInt(bigInteger a, bigInteger b);
/*
* restBigInt - compute the factorial of a number
* Arguments
* - unsigned long a - An integer, unsigned
*
* Return : bigInteger, a pointer on the result bigInteger, the factorial
*
*/
bigInteger factorial(unsigned long a);
/*
* cnpBigInt - compute the combinatorial of two integers n and p
* Arguments
* - bigInteger A - The first bigInteger
* - bigInteger B - The second one
*
* Return : bigInteger, a pointer on the result bigInteger, the rest
*
*/
bigInteger cnp(unsigned long n, unsigned long p);
/*
* printBigInteger - print on the screen a bigInteger
* Arguments
* - bigInteger nombre - The bigInteger you want to print
*
* Return : void
*
*/
void printBigInteger (bigInteger nombre);
/*
* isNull - test if a bigInteger is null or not
* Arguments
* - bigInteger nombre - The bigInteger you want to test
*
* Return
* - true if it's null
* - false otherwise
*
*/
Boolean isNull (bigInteger nombre);
/*
* compareBigInt - compare two bigIntegers
* Arguments
* - bigInteger nombre1 - The first bigInteger
* - biginteger nombre2 - The second
*
* Return :
* - 0 if equal
* - 1 if nombre1 > nombre2
* - (-1) if nombre1 < nombre 2
*
*/
int compareBigInt (bigInteger nombre1, bigInteger nombre2);
/*
* signBigInt - return the sign of the bigInteger
* Arguments
* - bigInteger a - The tested bigInteger
*
* Return :
* - 0 if null
* - 1 if a > 0
* - (-1) if a < 0
*
*/
int signBigInt(bigInteger a);
/*
* equalsBigInt - test the equality between two bigIntegers
* Arguments
* - bigInteger a - The first bigInteger
* - biginteger b - The second
*
* Return :
* - true if equal
* - false otherwise
*
*/
Boolean equalsBigInt(bigInteger a, bigInteger b);