/* Copyright (c) 2009 Ian Piumarta
 * All rights reserved.
 * See the file COPYING for details.
 */

#include "_mpint.h"

/* answer negative if a < b, zero if a = b, positive if a > b */

int mp_cmp(mp_t *a, mp_t *b)
{
  mp_size_t v= a->width, w= b->width;
  if (v > w) return +1;
  if (v < w) return -1;
  while (w--) {
    mp_digit_t da= _mp_digitAt(a, w);
    mp_digit_t db= _mp_digitAt(b, w);
    if (da != db) return da > db ? 1 : -1;
  }
  return 0;
}

