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

Function fxBigInt_ulsr1

xs/sources/xsBigInt.c:1315–1343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1313}
1314
1315txBigInt *fxBigInt_ulsr1(txMachine* the, txBigInt *r, txBigInt *a, txU4 sw)
1316{
1317 int wsz, bsz;
1318 int i, n;
1319
1320 wsz = sw / mxBigIntWordSize;
1321 bsz = sw % mxBigIntWordSize;
1322 n = a->size - wsz;
1323 if (n <= 0) {
1324 if (r == NULL) r = fxBigInt_alloc(the, 1);
1325 r->size = 1;
1326 r->data[0] = 0;
1327 return(r);
1328 }
1329 /* 'r' can be the same as 'a' */
1330 if (r == NULL)
1331 r = fxBigInt_alloc(the, n);
1332 if (bsz == 0) {
1333 c_memmove(r->data, &a->data[wsz], n * sizeof(txU4));
1334 r->size = n;
1335 }
1336 else {
1337 for (i = 0; i < n - 1; i++)
1338 r->data[i] = (a->data[i + wsz] >> bsz) | (a->data[i + wsz + 1] << (mxBigIntWordSize - bsz));
1339 r->data[i] = a->data[i + wsz] >> bsz;
1340 r->size = (n > 1 && r->data[n - 1] == 0) ? n - 1: n;
1341 }
1342 return(r);
1343}
1344
1345txBigInt *fxBigInt_nop(txMachine* the, txBigInt *r, txBigInt *a, txBigInt *b)
1346{

Callers 7

mont_reductionFunction · 0.85
mont_mulFunction · 0.85
fxBigInt_lslFunction · 0.85
fxBigInt_lsrFunction · 0.85
fxBigInt_expFunction · 0.85
fxBigInt_udivFunction · 0.85

Calls 1

fxBigInt_allocFunction · 0.85

Tested by

no test coverage detected