plan9port

[fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port # fast
git clone https://src.adamsgaard.dk/plan9port.git # slow
Log | Files | Refs | README | LICENSE Back to index

mpcmp.c (471B)


      1 #include "os.h"
      2 #include <mp.h>
      3 #include "dat.h"
      4 
      5 /* return neg, 0, pos as abs(b1)-abs(b2) is neg, 0, pos */
      6 int
      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
     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 }