Jūs esate

Compare two bignum'bers

If you're working with bignum'bers, you'll probalby need to compare those two - are they equal, bigger, smaller etc. So, these functions might be useful:
bool equal(const bignum_t *a, const bignum_t *b) { if (a->sig_digits != b->sig_digits) return FALSE;    /* Not equal */ int i = 0; for (i = 0; i < a->sig_digits; i++) if (a->digits[i] != b->digits[i]) return FALSE;    /* Not equal */ return TRUE;    /* Equal */ } /* Checks if a is not equal to b */ bool nequal(const bignum_t *a, const bignum_t *b) { return !equal(a, b); } /* Checks if a < b */ bool less(const bignum_t *a, const bignum_t *b) { if (a->sig_digits > b->sig_digits) return FALSE;    /* Greater */ int i = 0; for (i = 0; i < a->sig_digits; i++) if (a->digits[i] > b->digits[i]) return FALSE;    /* Greater */ return TRUE;    /* Less */ } /* Checks if a > b */ bool greater(const bignum_t *a, const bignum_t *b) { return less(b, a); }

Komentuoti