Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. //BigInteger.h
  2. #ifndef BIG_INTEGER_H
  3. #define BIG_INTEGER_H
  4.  
  5. /*
  6.  * BIG_INTEGER_MAX_SIZE is the size the struct will have,
  7.  * override this macro to obtain bigger integers otherwise
  8.  * default value is of 32 byte
  9.  */
  10. #ifndef BIG_INTEGER_MAX_SIZE
  11. #define BIG_INTEGER_MAX_SIZE 32
  12. #endif
  13. #define POSITIVE 1
  14. #define NEGATIVE -1
  15.  
  16.  
  17. typedef struct{
  18.  
  19.   unsigned char data[BIG_INTEGER_MAX_SIZE];
  20.   short sign;
  21.  
  22. }BigInteger;
  23. //----------------------------------------------Costructors----------------------------------------------------
  24. /*
  25.  * Standard method to initialize a BigInteger
  26.  * Format has to be like that:
  27.  * 3321 = {3,3,2,1}
  28.  */
  29. BigInteger* newBigInteger(int elements,int number[]);
  30.  
  31. /*
  32.  * newBigIntegerFromChar(char* ) expects the input formatted as a string
  33.  * like "8223123343456" input values not containing only digits
  34.  * will result in a NULL  
  35.  */
  36. BigInteger* newBigIntegerFromChar(char*);
  37.  
  38. BigInteger* newBigIntegerFromInt(int );
  39.  
  40. //----------------------------------------------Interfaces------------------------------------------------------
  41. /*
  42.  * Interface method to perform operations with BigInteger
  43.  *
  44.  */
  45. BigInteger* add(BigInteger* ,BigInteger* );
  46. BigInteger* sub(BigInteger* ,BigInteger* );
  47.  
  48. //-----------------------------------------------Utils----------------------------------------------------------
  49. void print(BigInteger* );
  50.  
  51. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement