source: trunk/include/bignum.h@ 206

Last change on this file since 206 was 1, checked in by katerina, 19 years ago

Initial import

File size: 2.4 KB
Line 
1#ifndef _BIGNUM_H_
2#define _BIGNUM_H_
3
4#include "internal.h"
5
6typedef struct big_struct bignum;
7
8#define BIG_SIGN_0 0
9#define BIG_SIGN_PLUS 1
10#define BIG_SIGN_MINUS -1
11
12#define BIG_OK 0
13#define BIG_MEMERR 1
14#define BIG_DIV_ZERO 2
15#define BIG_ARGERR 3
16
17#ifdef BIG_SHORT_NAMES
18#define big_set_big big_sb
19#define big_set_long big_sl
20#define big_set_ulong big_usl
21#define big_string big_rs
22#define big_leqp big_lq
23#define big_expt big_x
24#endif
25
26/* External variables to take care about when using the bignums */
27typedef int bigerr_t;
28extern int big_errno;
29extern char *big_end_string;
30
31/* External functions to enable use of bignums */
32extern bigerr_t big_init_pkg(void);
33extern void big_release_pkg(void);
34
35extern bigerr_t big_create(bignum *a);
36extern void big_destroy(bignum *a);
37
38extern unsigned long big_bitcount(bignum *a);
39
40extern bigerr_t big_set_big(bignum *a, bignum *b);
41extern void big_set_long(long n, bignum *a);
42extern void big_set_ulong(unsigned long n, bignum *a);
43extern bigerr_t big_set_string(char *numstr, int base, bignum *a);
44
45extern int big_long(bignum *a, long *n);
46extern int big_ulong(bignum *a, unsigned long *n);
47extern char *big_string(bignum *a, int base);
48
49extern int big_sign(bignum *a);
50extern bigerr_t big_abs(bignum *a, bignum *b);
51
52extern bigerr_t big_negate(bignum *a, bignum *b);
53
54extern int big_compare(bignum *a, bignum *b);
55extern int big_lessp(bignum *a, bignum *b);
56extern int big_leqp(bignum *a, bignum *b);
57extern int big_equalp(bignum *a, bignum *b);
58extern int big_geqp(bignum *a, bignum *b);
59extern int big_greaterp(bignum *a, bignum *b);
60
61extern int big_zerop(bignum *a);
62extern int big_evenp(bignum *a);
63extern int big_oddp(bignum *a);
64
65extern bigerr_t big_add(bignum *a, bignum *b, bignum *c);
66extern bigerr_t big_sub(bignum *a, bignum *b, bignum *c);
67
68extern bigerr_t big_mul(bignum *a, bignum *b, bignum *c);
69
70extern bigerr_t big_trunc(bignum *a, bignum *b, bignum *c, bignum *r);
71extern bigerr_t big_floor(bignum *a, bignum *b, bignum *c, bignum *r);
72extern bigerr_t big_ceil(bignum *a, bignum *b, bignum *c, bignum *r);
73extern bigerr_t big_round(bignum *a, bignum *b, bignum *c, bignum *r);
74
75extern bigerr_t big_random(bignum *a, bignum *b);
76
77extern bigerr_t big_expt(bignum *a, unsigned long z, bignum *x);
78extern bigerr_t big_exptmod(bignum *a_in, bignum *z_in, bignum *n, bignum *x);
79extern bigerr_t big_gcd(bignum *a, bignum *b, bignum *g);
80
81#ifndef NULL
82#define NULL 0
83#endif
84
85#endif /* _BIGNUM_H_ */
Note: See TracBrowser for help on using the repository browser.