mpcmp.c 465 B

12345678910111213141516171819202122232425262728
  1. #include "os.h"
  2. #include <mp.h>
  3. #include "dat.h"
  4. // return neg, 0, pos as abs(b1)-abs(b2) is neg, 0, pos
  5. int
  6. mpmagcmp(mpint *b1, mpint *b2)
  7. {
  8. int i;
  9. i = b1->top - b2->top;
  10. if(i)
  11. return i;
  12. return mpveccmp(b1->p, b1->top, b2->p, b2->top);
  13. }
  14. // return neg, 0, pos as b1-b2 is neg, 0, pos
  15. int
  16. mpcmp(mpint *b1, mpint *b2)
  17. {
  18. if(b1->sign != b2->sign)
  19. return b1->sign - b2->sign;
  20. if(b1->sign < 0)
  21. return mpmagcmp(b2, b1);
  22. else
  23. return mpmagcmp(b1, b2);
  24. }