Page 225 - ARM 64 Bit Assembly Language
P. 225

Integer mathematics 213


                   14
                   15  /* Bigints can be converted to integers.  If it won’t fit in an
                   16    integer, the program exits */
                   17  int bigint_to_int(bigint b);
                   18
                   19  /* To print a bigint, you must convert it to a string */
                   20  char *bigint_to_str(bigint b);
                   21
                   22  /* Memory management */
                   23  bigint bigint_alloc(int chunks);
                   24  void bigint_free(bigint b);
                   25
                   26  /* There are seven arithmetic operations */
                   27  bigint bigint_add(bigint l, bigint r);
                   28  bigint bigint_sub(bigint l, bigint r);
                   29  bigint bigint_mul(bigint l, bigint r);
                   30  bigint bigint_div(bigint l, bigint r);
                   31  bigint bigint_negate(bigint b);
                   32  bigint bigint_abs(bigint b);
                   33  bigint bigint_sqrt(bigint b);
                   34
                   35  /* Two shift operations (all bigints are signed, so there is no
                   36    such thing as an unsigned shift right) */
                   37  bigint bigint_shift_left(bigint l, int shamt);
                   38  bigint bigint_shift_right(bigint l, int shamt);
                   39
                   40  /* There are seven comparison operations.  They return 1 for true,
                   41     or 0 for false. */
                   42  int bigint_is_zero(bigint b);
                   43  int bigint_le(bigint l, bigint r);
                   44  int bigint_lt(bigint l, bigint r);
                   45  int bigint_ge(bigint l, bigint r);
                   46  int bigint_gt(bigint l, bigint r);
                   47  int bigint_eq(bigint l, bigint r);
                   48  int bigint_ne(bigint l, bigint r);
                   49
                   50  /* Low-level comparison. bigint_cmp compares two bigints
                   51    returns -1 if l<r
                   52    returns 0 if l==r
                   53    returns 1 if l>r */
                   54  int bigint_cmp(bigint l, bigint r);
                   55
                   56  /* Functions for binary input/output */
                   57  void bigint_write_binary(FILE *f, bigint x);
                   58  bigint bigint_read_binary(FILE *f);
                   59
                   60  #endif
   220   221   222   223   224   225   226   227   228   229   230