|
|
1.1 ! root 1: #include "mprec.h" ! 2: ! 3: ! 4: /* ! 5: * Mcmp compares the mint's pointed to by "a" and "b". It returns an ! 6: * int which is : ! 7: * greater than zero iff "a" > "b" ! 8: * less than zero ii "a" < "b" ! 9: * equal to zero iff "a" == "b". ! 10: */ ! 11: ! 12: mcmp(a, b) ! 13: register mint *a, *b; ! 14: { ! 15: register char *ap, *bp; ! 16: register unsigned count; ! 17: int sign; ! 18: ! 19: ap = a->val + a->len; ! 20: bp = b->val + b->len; ! 21: ! 22: /* first see if signs are different */ ! 23: sign = *(ap - 1) == NEFL; ! 24: if (sign != (*(bp - 1) == NEFL)) ! 25: return (sign ? -1 : 1); ! 26: ! 27: /* next see if lengths different */ ! 28: if (a->len != b->len) ! 29: return (sign ? b->len - a->len : a->len - b->len); ! 30: ! 31: /* finally see if any of the bytes are different */ ! 32: count = a->len; ! 33: while (count-- != 0) ! 34: if (*--ap != *--bp) ! 35: return (*ap - *bp); ! 36: return (0); ! 37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.