144 lines
3.8 KiB
C
144 lines
3.8 KiB
C
|
|
#ifndef BH_BIGINT_H
|
||
|
|
#define BH_BIGINT_H
|
||
|
|
|
||
|
|
#include "bh.h"
|
||
|
|
|
||
|
|
typedef struct bh_bigint_s bh_bigint_t;
|
||
|
|
|
||
|
|
bh_bigint_t *bh_bigint_new(void);
|
||
|
|
void bh_bigint_free(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_block(void);
|
||
|
|
|
||
|
|
int bh_bigint_clear(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_set(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *from);
|
||
|
|
|
||
|
|
int bh_bigint_set_int(bh_bigint_t *to,
|
||
|
|
int from);
|
||
|
|
|
||
|
|
int bh_bigint_set_uint(bh_bigint_t *to,
|
||
|
|
unsigned int from);
|
||
|
|
|
||
|
|
int bh_bigint_get_int(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
unsigned int bh_bigint_get_uint(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_set_int8(bh_bigint_t *to,
|
||
|
|
bh_int8_t from);
|
||
|
|
|
||
|
|
int bh_bigint_set_uint8(bh_bigint_t *to,
|
||
|
|
bh_uint8_t from);
|
||
|
|
|
||
|
|
bh_int8_t bh_bigint_get_int8(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
bh_uint8_t bh_bigint_get_uint8(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_set_int16(bh_bigint_t *to,
|
||
|
|
bh_int16_t from);
|
||
|
|
|
||
|
|
int bh_bigint_set_uint16(bh_bigint_t *to,
|
||
|
|
bh_uint16_t from);
|
||
|
|
|
||
|
|
bh_int16_t bh_bigint_get_int16(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
bh_uint16_t bh_bigint_get_uint16(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_set_int32(bh_bigint_t *to,
|
||
|
|
bh_int32_t from);
|
||
|
|
|
||
|
|
int bh_bigint_set_uint32(bh_bigint_t *to,
|
||
|
|
bh_uint32_t from);
|
||
|
|
|
||
|
|
bh_int32_t bh_bigint_get_int32(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
bh_uint32_t bh_bigint_get_uint32(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_set_int64(bh_bigint_t *to,
|
||
|
|
bh_int64_t from);
|
||
|
|
|
||
|
|
int bh_bigint_set_uint64(bh_bigint_t *to,
|
||
|
|
bh_uint64_t from);
|
||
|
|
|
||
|
|
bh_int64_t bh_bigint_get_int64(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
bh_uint64_t bh_bigint_get_uint64(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
size_t bh_bigint_capacity(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
size_t bh_bigint_length(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
int bh_bigint_reserve(bh_bigint_t *bigint,
|
||
|
|
size_t size);
|
||
|
|
|
||
|
|
int bh_bigint_add(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_sub(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_mul(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_pow(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *from,
|
||
|
|
bh_uint32_t power);
|
||
|
|
|
||
|
|
int bh_bigint_powm(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right,
|
||
|
|
bh_bigint_t *mod);
|
||
|
|
|
||
|
|
int bh_bigint_divmod(bh_bigint_t *quotient,
|
||
|
|
bh_bigint_t *remainder,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_div(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_mod(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_lsh(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *from,
|
||
|
|
bh_uint32_t shift);
|
||
|
|
|
||
|
|
int bh_bigint_rsh(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *from,
|
||
|
|
bh_uint32_t shift);
|
||
|
|
|
||
|
|
int bh_bigint_or(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_and(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_xor(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_negate(bh_bigint_t *to,
|
||
|
|
bh_bigint_t *from);
|
||
|
|
|
||
|
|
int bh_bigint_equal(bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_equal_mod(bh_bigint_t *left,
|
||
|
|
bh_bigint_t *right);
|
||
|
|
|
||
|
|
int bh_bigint_is_negative(bh_bigint_t *bigint);
|
||
|
|
int bh_bigint_is_zero(bh_bigint_t *bigint);
|
||
|
|
int bh_bigint_is_error(bh_bigint_t *bigint);
|
||
|
|
size_t bh_bigint_log2(bh_bigint_t *bigint);
|
||
|
|
|
||
|
|
#endif /* BH_BIGINT_H */
|