Guest User

Untitled

a guest
Dec 11th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #ifndef BIGINT_T_H
  2. #define BIGINT_T_H
  3.  
  4. #define BIGINT_MAX_ORDERS 30 // size
  5. #define BIGINT_BASE 0x10000 // max for word(short int(x86))
  6. #define BIGINT_BITPERREG 16
  7.  
  8. typedef unsigned short int WORD;
  9. typedef unsigned short int *PWORD;
  10. typedef unsigned long DWORD;
  11.  
  12. typedef int BIGINT_ITERATOR;
  13. typedef WORD BIGINT_DATA;
  14. typedef PWORD PBIGINT_DATA;
  15. typedef DWORD BIGINT_SIZE;
  16. typedef long BIGINT_ARITHMETIC;
  17. typedef short BIGINT_UTILITY;
  18. typedef WORD* PBIGINT_CARRY;
  19.  
  20. /*typedef enum sign_t {
  21. MINUS,
  22. PLUS
  23. } SIGN_T;*/
  24.  
  25. typedef struct bigint_t {
  26. //SIGN_T sign;
  27. BIGINT_DATA data[BIGINT_MAX_ORDERS];
  28. BIGINT_SIZE size;
  29. } BIGINT_T, *PBIGINT_T;
  30.  
  31. // init functions
  32. BIGINT_T bigint_make(/*SIGN_T sign,*/ PBIGINT_DATA p_data, BIGINT_SIZE size);
  33. PBIGINT_T bigint_set (PBIGINT_T p_result, /*SIGN_T sign,*/ PBIGINT_DATA p_data, BIGINT_SIZE size);
  34. PBIGINT_T bigint_cpy (PBIGINT_T p_result, PBIGINT_T p_from);
  35.  
  36. // compare functions
  37. // 0 - equal // 1 - arg1 > arg2 // -1 - arg1 < arg2
  38. BIGINT_UTILITY bigint_compare (PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  39. BIGINT_UTILITY bigint_compare_b(PBIGINT_T p_arg1, BIGINT_DATA arg2);
  40.  
  41. // arithmetic functions
  42. PBIGINT_T bigint_shr(PBIGINT_T p_result, PBIGINT_T p_arg, BIGINT_SIZE offset /* if digit */);
  43. PBIGINT_T bigint_shl(PBIGINT_T p_result, PBIGINT_T p_arg, BIGINT_SIZE offset /* if digit */);
  44.  
  45. PBIGINT_T bigint_add (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  46. PBIGINT_T bigint_add_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
  47. // arg1 > arg2 only!
  48. PBIGINT_T bigint_sub (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  49. // arg1 > arg2 only!
  50. PBIGINT_T bigint_sub_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
  51. PBIGINT_T bigint_mul (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  52. PBIGINT_T bigint_mul_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
  53. PBIGINT_T bigint_div (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  54. PBIGINT_T bigint_div_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
  55. PBIGINT_T bigint_mod (PBIGINT_T p_result, PBIGINT_T p_arg1, PBIGINT_T p_arg2);
  56. PBIGINT_T bigint_mod_b(PBIGINT_T p_result, PBIGINT_T p_arg1, BIGINT_DATA arg2);
  57.  
  58. // utility function
  59. void bigint_print(PBIGINT_T p_arg);
  60. char* bigint_tostr(char* p_result , PBIGINT_T p_arg, BIGINT_UTILITY base);
  61.  
  62.  
  63. #endif // BIGINT_T_H
Add Comment
Please, Sign In to add comment