|
|
1.1 root 1: #include "mprec.h"
2:
3:
4: /*
5: * Norm normalizes the mint pointed to by "a". This simply entails
6: * propogating any carry and truncating any leading 00 or NEFL bytes.
7: * Note that norm assumes that there is enough room for the result.
8: */
9:
10: void
11: norm(a)
12: mint *a;
13: {
14: register unsigned char *ap, *limit;
15: register int carry;
16:
17: ap = (unsigned char *)a->val;
18: limit = ap + a->len;
19: carry = 0;
20: do {
21: carry += *ap;
22: *ap++ = carry % BASE;
23: carry >>= L2BASE;
24: } while (ap < limit);
25: --ap;
26: limit = a->val;
27: if (*ap == NEFL) {
28: while (*ap == NEFL && ap >= limit)
29: --ap;
30: ++ap;
31: } else {
32: while (*ap == 0 && ap > limit)
33: --ap;
34: if (*ap == NEFL)
35: ++ap;
36: }
37: a->len = 1 + ap - a->val;
38: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.