aboutsummaryrefslogtreecommitdiff
path: root/BigInt.h
blob: 939d1d13ea3e51c740ddc616027becf659989233 (plain) (blame)
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
#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 */