#ifndef BIGNUM_H
#define BINNUM_H

typedef struct BigNum_tag *BigNum;

#define B BigNum

/*
   Convert an ascii string to a BigNum. Caller needs to free
   the BigNum returned after using it.
*/
extern B BigNum_fromString(const char *str);

/*
   Convert a BigNum to string. Caller needs to free
   the string returned after using it.
*/
extern char* BigNum_toString(B b);

/*
   Given two BigNums b1 and b2, perform the appropriate operation and
   returns the resulting BigNum. Again the caller needs to free
   the BigNum returned.
*/
extern B BigNum_add(B b1, B b2); /* addition */
extern B BigNum_sub(B b1, B b2); /* subtraction */
extern B BigNum_mul(B b1, B b2); /* multiplication */
extern B BigNum_div(B b1, B b2); /* division */
extern B BigNum_rem(B b1, B b2); /* modulo */
extern B BigNum_exp(B b1, B b2); /* exponentiation */

/*
   Given two BigNums b1 and b2, perform the appropriate comparison and
   returns the BigNum 1 if true, or the BigNum 0 if false. Again the caller
   needs to free the BigNum returned.
*/
extern B BigNum_eq(B b1, B b2);  /* equality */
extern B BigNum_gt(B b1, B b2);  /* greater than */
extern B BigNum_lt(B b1, B b2);  /* less than */

extern B BigNum_neg(B b);        /* unary negation */

extern B BigNum_clone(B b);      /* cloning */

extern void BigNum_free(B b);

#undef B
#endif

