110 lines
2.5 KiB
C
110 lines
2.5 KiB
C
/*
|
|
multiprecision.h by Noam HACHE
|
|
|
|
This file contains the type definition of lentier, representing an integer of over 64bits,
|
|
and functions related to the addition, substraction, multiplication, division and comparaison of this lentier type.
|
|
*/
|
|
|
|
|
|
// Type definition of a "long int"
|
|
typedef struct {
|
|
unsigned int *p;
|
|
unsigned int size;
|
|
} lentier;
|
|
|
|
/*
|
|
Add 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the addition of the 2 operands
|
|
*/
|
|
struct lentier Add_lentier(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Substract 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the substraction of the 2 operands
|
|
*/
|
|
struct lentier Sub_lentier(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Compare 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
a char, 0 if the operands are identical
|
|
1 if a is greater than b
|
|
-1 if a is lower than b
|
|
*/
|
|
char Cmp_lentier(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Multiply 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the multiplication of the 2 operands
|
|
*/
|
|
struct lentier Mult_classique(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Euclidean division of 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the rest of the euclidean division of the 2 operands
|
|
*/
|
|
struct lentier Div_eucl(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Modular multiplication of 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the modular multiplication of the 2 operands
|
|
*/
|
|
struct lentier Mul_mod(struct lentier a, struct lentier b);
|
|
|
|
/*
|
|
Modular exponentiation of 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the modular exponentiation of the 2 operands
|
|
*/
|
|
struct lentier Exp_mod(struct lentier a, struct lentier x, struct lentier N);
|
|
|
|
/*
|
|
Modular exponentiation of 2 lentier
|
|
|
|
Args:
|
|
a (lentier): the first operand
|
|
b (lentier): the second operand
|
|
|
|
Returns:
|
|
an lentier, the modular exponentiation of the 2 operands
|
|
*/ |