#ifndef _BIGINT
#define _BIGINT

#include "MemoryManager.h"

typedef void* BigInt;

/* Create */

BigInt B_new(MemoryManager *mm, int value);
BigInt B_newstr(MemoryManager *mm, const char* str);
BigInt B_newbytes(MemoryManager *mm, usize bytes);
BigInt B_dup(MemoryManager *mm, const BigInt bigint);

/* Free */

Result B_free(BigInt *bigint);

/* Modify */

Result B_sum(BigInt *a, const BigInt b);
Result B_sub(BigInt *a, const BigInt b);

Result B_compl(BigInt *x);
Result B_bitand(BigInt *x, const BigInt y);
Result B_bitor(BigInt *x, const BigInt y);
Result B_bitxor(BigInt *x, const BigInt y);
Result B_rshift(BigInt *x, usize shift);
Result B_lshift(BigInt *x, usize shift);

/* Get */

usize B_bits(const BigInt x);
usize B_bitwidth(const BigInt x);
char* B_tostr(MemoryManager *mm, const BigInt x);

int B_eq(const BigInt x, const BigInt y);
int B_not_eq(const BigInt x, const BigInt y);
int B_lt(const BigInt x, const BigInt y);
int B_le(const BigInt x, const BigInt y);
int B_gt(const BigInt x, const BigInt y);
int B_ge(const BigInt x, const BigInt y);

#endif /* _BIGINT */
