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