Lines Matching refs:b

337 #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \  argument
340 #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ argument
476 #define rounded_product(a,b) a = rnd_prod(a, b) argument
477 #define rounded_quotient(a,b) a = rnd_quot(a, b) argument
484 #define rounded_product(a,b) a *= b argument
485 #define rounded_quotient(a,b) a /= b argument
660 (b, m, a) Bigint *b; int m, a; in multadd() argument
662 (Bigint *b, int m, int a) /* multiply by m and add a */
677 wds = b->wds;
678 x = b->x;
702 if (wds >= b->maxwds) {
703 b1 = Balloc(b->k+1);
704 Bcopy(b1, b);
705 Bfree(b);
706 b = b1;
708 b->x[wds++] = carry;
709 b->wds = wds;
711 return b;
722 Bigint *b; local
729 b = Balloc(k);
730 b->x[0] = y9;
731 b->wds = 1;
733 b = Balloc(k+1);
734 b->x[0] = y9 & 0xffff;
735 b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
741 do b = multadd(b, 10, *s++ - '0');
748 b = multadd(b, 10, *s++ - '0');
749 return b;
842 Bigint *b; local
844 b = Balloc(1);
845 b->x[0] = i;
846 b->wds = 1;
847 return b;
853 (a, b) Bigint *a, *b; in mult() argument
855 (Bigint *a, Bigint *b)
871 if (a->wds < b->wds) {
873 a = b;
874 b = c;
878 wb = b->wds;
887 xb = b->x;
965 (b, k) Bigint *b; int k; in pow5mult() argument
967 (Bigint *b, int k)
975 b = multadd(b, p05[i-1], 0);
978 return b;
995 b1 = mult(b, p5);
996 Bfree(b);
997 b = b1;
1016 return b;
1022 (b, k) Bigint *b; int k; in lshift() argument
1024 (Bigint *b, int k)
1036 k1 = b->k;
1037 n1 = n + b->wds + 1;
1038 for(i = b->maxwds; n1 > i; i <<= 1)
1044 x = b->x;
1045 xe = x + b->wds;
1075 Bfree(b);
1082 (a, b) Bigint *a, *b; in cmp() argument
1084 (Bigint *a, Bigint *b)
1091 j = b->wds;
1095 if (j > 1 && !b->x[j-1])
1102 xb0 = b->x;
1116 (a, b) Bigint *a, *b; in diff() argument
1118 (Bigint *a, Bigint *b)
1133 i = cmp(a,b);
1142 a = b;
1143 b = c;
1153 wb = b->wds;
1154 xb = b->x;
1327 Bigint *b; local
1343 b = Balloc(1);
1345 b = Balloc(2);
1347 x = b->x;
1371 b->wds = (x[1] = z) ? 2 : 1;
1379 b->wds = 1;
1425 b->wds = i + 1;
1448 return b;
1456 (a, b) Bigint *a, *b; in ratio() argument
1458 (Bigint *a, Bigint *b)
1465 dval(&db) = b2d(b, &kb);
1467 k = ka - kb + 32*(a->wds - b->wds);
1469 k = ka - kb + 16*(a->wds - b->wds);
1700 increment(b) Bigint *b; in increment() argument
1702 increment(Bigint *b)
1708 x = b->x;
1709 xe = x + b->wds;
1713 return b;
1718 if (b->wds >= b->maxwds) {
1719 b1 = Balloc(b->k+1);
1720 Bcopy(b1,b);
1721 Bfree(b);
1722 b = b1;
1724 b->x[b->wds++] = 1;
1726 return b;
1735 rshift(b, k) Bigint *b; int k; in rshift() argument
1737 rshift(Bigint *b, int k)
1743 x = x1 = b->x;
1745 if (n < b->wds) {
1746 xe = x + b->wds;
1762 if ((b->wds = x1 - b->x) == 0)
1763 b->x[0] = 0;
1768 any_on(b, k) Bigint *b; int k; in any_on() argument
1770 any_on(Bigint *b, int k)
1776 x = b->x;
1777 nwds = b->wds;
1811 Bigint *b; local
1954 Bfree(b);
1984 b = Balloc(k);
1985 x = b->x;
2010 b->wds = n = x - b->x;
2014 x = b->x;
2017 if (any_on(b,n)) {
2022 if (k > 0 && any_on(b,k))
2026 rshift(b, n);
2031 b = lshift(b, n);
2033 x = b->x;
2037 Bfree(b);
2054 if (n == nbits && (n < 2 || any_on(b,n-1)))
2066 Bfree(b);
2079 lostbits = any_on(b,k);
2083 rshift(b,n);
2103 k = b->wds;
2104 b = increment(b);
2105 x = b->x;
2113 else if (b->wds > k
2116 rshift(b,1);
2124 word0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0;
2126 word0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20);
2127 word1(rvp) = b->x[0];
2131 k = b->x[0] & ((1 << j) - 1);
2132 rshift(b,j);
2137 increment(b);
2141 increment(b);
2146 increment(b);
2151 word0(rvp) = b->x[1] | ((e + 65 + 13) << 24);
2152 word1(rvp) = b->x[0];
2158 word0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16);
2159 word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16);
2161 Bfree(b);
2167 dshift(b, p2) Bigint *b; int p2; in dshift() argument
2169 dshift(Bigint *b, int p2)
2172 int rv = hi0bits(b->x[b->wds-1]) - 4;
2181 (b, S) Bigint *b, *S; in quorem() argument
2183 (Bigint *b, Bigint *S)
2199 /*debug*/ if (b->wds > n)
2202 if (b->wds < n)
2206 bx = b->x;
2251 bx = b->x;
2254 b->wds = n;
2257 if (cmp(b, S) >= 0) {
2261 bx = b->x;
2291 bx = b->x;
2296 b->wds = n;
2334 Bigint *b, *d; local
2345 b = i2b(1);
2366 b = d2b(rv, &p2, &bbits);
2375 Bfree(b);
2376 b = i2b(1);
2392 b = lshift(b, i);
2394 b = increment(b);
2399 b = lshift(b, ++i);
2400 b->x[0] |= 1;
2413 b = pow5mult(b, -p5);
2424 b = lshift(b, b2);
2431 if (!(dig = quorem(b,d))) {
2432 b = multadd(b, 10, 0); /* very unlikely */
2433 dig = quorem(b,d);
2441 if (!b->x[0] && b->wds == 1) {
2446 b = multadd(b, 10, 0);
2447 dig = quorem(b,d);
2452 if (!b->x[0] && b->wds == 1) {
2457 b = multadd(b, 10, 0);
2458 dig = quorem(b,d);
2460 if (dig > 0 || b->x[0] || b->wds > 1)
2463 Bfree(b);
3670 Bigint *b = (Bigint *)((int *)s - 1); local
3671 b->maxwds = 1 << (b->k = *(int*)b);
3672 Bfree(b);
3764 Bigint *b, *b1, *delta, *mlo, *mhi, *S; local
3844 b = d2b(&u, &be, &bbits);
4177 b1 = mult(mhi, b);
4178 Bfree(b);
4179 b = b1;
4182 b = pow5mult(b, j);
4185 b = pow5mult(b, b5);
4223 b = lshift(b, b2);
4227 if (cmp(b,S) < 0) {
4229 b = multadd(b, 10, 0); /* we botched the k estimate */
4236 if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
4263 dig = quorem(b,S) + '0';
4267 j = cmp(b, mlo);
4269 j1 = delta->sign ? 1 : cmp(b, delta);
4282 else if (!b->x[0] && b->wds <= 1)
4294 if (!b->x[0] && b->wds <= 1) {
4308 b = lshift(b, 1);
4309 j1 = cmp(b, S);
4341 b = multadd(b, 10, 0);
4352 *s++ = dig = quorem(b,S) + '0';
4353 if (!b->x[0] && b->wds <= 1) {
4361 b = multadd(b, 10, 0);
4372 b = lshift(b, 1);
4373 j = cmp(b, S);
4415 Bfree(b);