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

Function div64_32

xs/sources/xsBigInt.c:1787–1811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785
1786#if BN_NO_ULDIVMOD
1787static txU8
1788div64_32(txU8 a, txU4 b)
1789{
1790 txU4 high = (txU4)(a >> 32);
1791 txU8 r = 0, bb = b, d = 1;
1792
1793 if (high >= b) {
1794 high /= b;
1795 r = (txU8)high << 32;
1796 a -= (txU8)(high * b) << 32;
1797 }
1798 while ((long long)bb > 0 && bb < a) {
1799 bb += bb;
1800 d += d;
1801 }
1802 do {
1803 if (a >= bb) {
1804 a -= bb;
1805 r += d;
1806 }
1807 bb >>= 1;
1808 d >>= 1;
1809 } while (d != 0);
1810 return r;
1811}
1812#endif
1813
1814txBigInt *fxBigInt_udiv(txMachine* the, txBigInt *q, txBigInt *a, txBigInt *b, txBigInt **r)

Callers 1

fxBigInt_udivFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected