MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBigInt_umul

Function fxBigInt_umul

xs/sources/xsBigInt.c:1555–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1553}
1554
1555txBigInt *fxBigInt_umul(txMachine* the, txBigInt *rr, txBigInt *aa, txBigInt *bb)
1556{
1557 txU8 a, b, r;
1558 txU4 *ap, *bp, *rp;
1559 txU4 c = 0;
1560 int i, j, n, m;
1561
1562 if (rr == NULL)
1563 rr = fxBigInt_alloc(the, aa->size + bb->size);
1564 fxBigInt_fill0(rr);
1565 ap = aa->data;
1566 bp = bb->data;
1567 rp = rr->data;
1568 n = bb->size;
1569 for (i = 0, j = 0; i < n; i++) {
1570 b = (txU8)bp[i];
1571 c = 0;
1572 m = aa->size;
1573 for (j = 0; j < m; j++) {
1574 a = (txU8)ap[j];
1575 r = a * b + c;
1576 r += (txU8)rp[i + j];
1577 rp[i + j] = mxBigIntLowWord(r);
1578 c = mxBigIntHighWord(r);
1579 }
1580 rp[i + j] = c;
1581 }
1582 /* remove leading 0s */
1583 for (n = i + j; --n > 0 && rp[n] == 0;)
1584 ;
1585 rr->size = n + 1;
1586 rr->sign = 0;
1587 return(rr);
1588}
1589
1590txBigInt *fxBigInt_umul1(txMachine* the, txBigInt *r, txBigInt *a, txU4 b)
1591{

Callers 2

fxBigInt_mulFunction · 0.85
fxBigInt_expFunction · 0.85

Calls 2

fxBigInt_allocFunction · 0.85
fxBigInt_fill0Function · 0.85

Tested by

no test coverage detected