-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbignbr.h
44 lines (33 loc) · 998 Bytes
/
bignbr.h
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 __BIGNBR_H__
#define __BIGNBR_H__
// END OF NUMBER
#define BIGNBR_EON 'E'
// SIGN
#define BIGNBR_SIGN 0
#define BIGNBR_GETNBR(a) ((a) == (BIGNBR_EON) ? (0) : (a))
struct _bignbr
{
size_t len;
char *data;
};
typedef struct _bignbr bignbr;
// Core
void bignbr_init (bignbr*, const size_t, const char*);
void bignbr_free (bignbr*);
void bignbr_cpy (bignbr*, const bignbr*);
void bignbr_cat_digit (bignbr*, const char);
void bignbr_fill (bignbr*, const char*);
void bignbr_print (const bignbr*);
size_t bignbr_get_eon_pos (const bignbr*);
// Check
bool bignbr_cmp_str (const bignbr*, const char*);
bool bignbr_is_null (const bignbr*);
void bignbr_set_negative (bignbr*, const bool);
bool bignbr_is_negative (const bignbr*);
bool bignbr_is_greater (const bignbr*, const bignbr*);
// Arithmetic
void bignbr_add (bignbr*, bignbr*);
void bignbr_sub (bignbr*, bignbr*);
void bignbr_mpl (bignbr*, bignbr*);
void bignbr_div (bignbr*, bignbr*, bignbr*, bignbr*);
#endif /* __BIGNBR_H__ */