Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef BIGINT_T_H
- #define BIGINT_T_H
- #define BIGINT_MAX_ORDERS 30 // size
- #define BIGINT_BASE 0x10000 // max for word(short int(x86))
- #define BIGINT_BITPERREG 16
- typedef unsigned short int WORD;
- typedef unsigned short int *PWORD;
- typedef unsigned long DWORD;
- typedef int BIGINT_ITERATOR;
- typedef WORD BIGINT_DATA;
- typedef PWORD PBIGINT_DATA;
- typedef DWORD BIGINT_SIZE;
- typedef long BIGINT_ARITHMETIC;
- typedef short BIGINT_UTILITY;
- typedef WORD* PBIGINT_CARRY;
- /*typedef enum sign_t {
- MINUS,
- PLUS
- } SIGN_T;*/
- typedef struct bigint_t {
- //SIGN_T sign;
- BIGINT_DATA data[BIGINT_MAX_ORDERS];
- BIGINT_SIZE size;
- } BIGINT_T, *PBIGINT_T;
- // init functions
- BIGINT_T bigint_make(/*SIGN_T sign,*/ PBIGINT_DATA p_data, BIGINT_SIZE size);
- PBIGINT_T bigint_set (PBIGINT_T p_result, /*SIGN_T sign,*/ PBIGINT_DATA p_data, BIGINT_SIZE size);
- PBIGINT_T bigint_cpy (PBIGINT_T p_result, PBIGINT_T p_from);
- // compare functions
- // 0 - equal // 1 - arg1 > arg2 // -1 - arg1 < arg2
- BIGINT_UTILITY bigint_compare (PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- BIGINT_UTILITY bigint_compare_b(PBIGINT_T p_arg1, BIGINT_DATA arg2);
- // arithmetic functions
- PBIGINT_T bigint_shr(PBIGINT_T p_result, PBIGINT_T p_arg, BIGINT_SIZE offset /* if digit */);
- PBIGINT_T bigint_shl(PBIGINT_T p_result, PBIGINT_T p_arg, BIGINT_SIZE offset /* if digit */);
- PBIGINT_T bigint_add (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- PBIGINT_T bigint_add_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
- // arg1 > arg2 only!
- PBIGINT_T bigint_sub (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- // arg1 > arg2 only!
- PBIGINT_T bigint_sub_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
- PBIGINT_T bigint_mul (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- PBIGINT_T bigint_mul_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
- PBIGINT_T bigint_div (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- PBIGINT_T bigint_div_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
- PBIGINT_T bigint_mod (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
- PBIGINT_T bigint_mod_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
- // utility function
- void bigint_print(PBIGINT_T p_arg);
- char* bigint_tostr(char* p_result , PBIGINT_T p_arg, BIGINT_UTILITY base);
- #endif // BIGINT_T_H
Add Comment
Please, Sign In to add comment