diff options
Diffstat (limited to 'all_pairs/source/ammunition/arithm.h')
| -rw-r--r-- | all_pairs/source/ammunition/arithm.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/all_pairs/source/ammunition/arithm.h b/all_pairs/source/ammunition/arithm.h new file mode 100644 index 0000000..8ed78bf --- /dev/null +++ b/all_pairs/source/ammunition/arithm.h | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | /* | ||
| 2 | FILE NAME: arithm.h | ||
| 3 | |||
| 4 | TITLE: Include file of package for arbitrary precision integer | ||
| 5 | arithmetic | ||
| 6 | |||
| 7 | DESCRIPTION: This header file contains ANSI C prototype definitions of | ||
| 8 | the package functions and definitions of external | ||
| 9 | variable of the package and C++ classes for arbitrary | ||
| 10 | precision integer arithmetic. | ||
| 11 | |||
| 12 | */ | ||
| 13 | |||
| 14 | |||
| 15 | #ifndef __ARITHMETIC__ | ||
| 16 | #define __ARITHMETIC__ | ||
| 17 | |||
| 18 | #include "ammunition_limits.h" | ||
| 19 | |||
| 20 | |||
| 21 | /* This page contains definitions of variables and macros common for | ||
| 22 | all package functions. */ | ||
| 23 | |||
| 24 | /* The value of macro is suggested to be maximum length of integer operands | ||
| 25 | The length of use integers should be not greater than this value. */ | ||
| 26 | |||
| 27 | #define MAX_INTEGER_OPERAND_SIZE 128 | ||
| 28 | |||
| 29 | /* The following macro value is sign of integer number (0 or 1) given | ||
| 30 | as macro parameter. */ | ||
| 31 | |||
| 32 | #define INTEGER_SIGN(operand) (*(unsigned char *) (operand) >> (CHAR_BIT - 1)) | ||
| 33 | |||
| 34 | extern int ammunition_overflow_bit; | ||
| 35 | |||
| 36 | extern void ammunition_add_unsigned_integer ( int size, const void *op1, | ||
| 37 | const void *op2, | ||
| 38 | void *result ); | ||
| 39 | extern void ammunition_add_integer ( int size, const void *op1, const void *op2, | ||
| 40 | void *result ); | ||
| 41 | extern void ammunition_subtract_unsigned_integer ( int size, const void *op1, | ||
| 42 | const void *op2, void *result ); | ||
| 43 | extern void ammunition_subtract_integer ( int size, const void *op1, | ||
| 44 | const void *op2, | ||
| 45 | void *result ); | ||
| 46 | extern void ammunition_multiply_unsigned_integer ( int size, const void *op1, | ||
| 47 | const void *op2, void *result ); | ||
| 48 | extern void ammunition_multiply_integer ( int size, const void *op1, | ||
| 49 | const void *op2, | ||
| 50 | void *result ); | ||
| 51 | extern void ammunition_divide_unsigned_integer ( int size, const void *op1, | ||
| 52 | const void *op2, void *result ); | ||
| 53 | extern void ammunition_divide_integer ( int size, const void *op1, | ||
| 54 | const void *op2, | ||
| 55 | void *result ); | ||
| 56 | extern void ammunition_unsigned_integer_remainder ( int size, const void *op1, | ||
| 57 | const void *op2, void *result ); | ||
| 58 | |||
| 59 | extern void ammunition_unsigned_integer_shift_right ( int size, | ||
| 60 | const void *operand, | ||
| 61 | int bits, void *result ); | ||
| 62 | extern void ammunition_integer_shift_right ( int size, const void *operand, | ||
| 63 | int bits, void *result ); | ||
| 64 | extern void ammunition_integer_shift_left ( int size, const void *operand, | ||
| 65 | int bits, void *result ); | ||
| 66 | extern void ammunition_unsigned_integer_shift_left ( int size, | ||
| 67 | const void *operand, | ||
| 68 | int bits, void *result ); | ||
| 69 | |||
| 70 | extern void ammunition_integer_or ( int size, const void *op1, | ||
| 71 | const void *op2, void *result ); | ||
| 72 | extern void ammunition_unsigned_integer_or ( int size, const void *op1, | ||
| 73 | const void *op2, void *result ); | ||
| 74 | extern void ammunition_integer_and ( int size, const void *op1, | ||
| 75 | const void *op2, void *result ); | ||
| 76 | extern void ammunition_unsigned_integer_and ( int size, const void *op1, | ||
| 77 | const void *op2, void *result ); | ||
| 78 | extern void ammunition_integer_not ( int size, const void *operand, | ||
| 79 | void *result ); | ||
| 80 | extern void ammunition_unsigned_integer_not ( int size, const void *operand, | ||
| 81 | void *result ); | ||
| 82 | |||
| 83 | extern int ammunition_eq_unsigned_integer ( int size, const void *op1, | ||
| 84 | const void *op2 ); | ||
| 85 | extern int ammunition_eq_integer ( int size, const void *op1, const void *op2 ); | ||
| 86 | extern int ammunition_ne_unsigned_integer ( int size, const void *op1, | ||
| 87 | const void *op2 ); | ||
| 88 | extern int ammunition_ne_integer ( int size, const void *op1, const void *op2 ); | ||
| 89 | extern int ammunition_gt_unsigned_integer ( int size, const void *op1, | ||
| 90 | const void *op2 ); | ||
| 91 | extern int ammunition_gt_integer ( int size, const void *op1, const void *op2 ); | ||
| 92 | extern int ammunition_lt_unsigned_integer ( int size, const void *op1, | ||
| 93 | const void *op2 ); | ||
| 94 | extern int ammunition_lt_integer ( int size, const void *op1, const void *op2 ); | ||
| 95 | extern int ammunition_ge_unsigned_integer ( int size, const void *op1, | ||
| 96 | const void *op2 ); | ||
| 97 | extern int ammunition_ge_integer ( int size, const void *op1, const void *op2 ); | ||
| 98 | extern int ammunition_le_unsigned_integer ( int size, const void *op1, | ||
| 99 | const void *op2 ); | ||
| 100 | extern int ammunition_le_integer ( int size, const void *op1, const void *op2 ); | ||
| 101 | |||
| 102 | extern void ammunition_change_unsigned_integer_size | ||
| 103 | ( int operand_size, const void *operand, int result_size, void *result ); | ||
| 104 | extern void ammunition_change_integer_size ( int operand_size, | ||
| 105 | const void *operand, | ||
| 106 | int result_size, void *result ); | ||
| 107 | |||
| 108 | extern char *ammunition_unsigned_integer_to_string ( int size, | ||
| 109 | const void *operand, | ||
| 110 | char *result ); | ||
| 111 | extern char *ammunition_integer_to_string ( int size, const void *operand, | ||
| 112 | char *result ); | ||
| 113 | |||
| 114 | extern char *ammunition_unsigned_integer_from_string ( int size, | ||
| 115 | const char *operand, | ||
| 116 | void *result ); | ||
| 117 | extern char *ammunition_integer_from_string ( int size, const char *operand, | ||
| 118 | void *result ); | ||
| 119 | |||
| 120 | char ammunition_isdigit( unsigned char c ); | ||
| 121 | int ammunition_isspace( int c ); | ||
| 122 | |||
| 123 | #endif /* #ifndef __ARITHMETIC__ */ | ||
