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

Function fxBigInt_umul1

xs/sources/xsBigInt.c:1590–1617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1588}
1589
1590txBigInt *fxBigInt_umul1(txMachine* the, txBigInt *r, txBigInt *a, txU4 b)
1591{
1592 int i, n;
1593 txU4 c = 0;
1594 txU4 *ap, *rp;
1595 txU8 wa, wr;
1596
1597 if (r == NULL)
1598 r = fxBigInt_alloc(the, a->size + 1);
1599 ap = a->data;
1600 rp = r->data;
1601 n = a->size;
1602 for (i = 0; i < n; i++) {
1603 wa = (txU8)ap[i];
1604 wr = wa * b + c;
1605 c = mxBigIntHighWord(wr);
1606 rp[i] = mxBigIntLowWord(wr);
1607 }
1608 if (c != 0)
1609 rp[i] = c;
1610 else {
1611 /* remove leading 0s */
1612 while (--i > 0 && rp[i] == 0)
1613 ;
1614 }
1615 r->size = i + 1;
1616 return(r);
1617}
1618
1619txBigInt *fxBigInt_exp(txMachine* the, txBigInt *r, txBigInt *a, txBigInt *b)
1620{

Callers 5

mont_reductionFunction · 0.85
mont_mulFunction · 0.85
fxBigIntParseFunction · 0.85
fxBigInt_expFunction · 0.85
fxBigInt_udivFunction · 0.85

Calls 1

fxBigInt_allocFunction · 0.85

Tested by

no test coverage detected