MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / init

Method init

code/mathematics/intx.cpp:12–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 static const unsigned int radix = 1000000000U;
11 int size() const { return data.size(); }
12 void init(string n) {
13 intx res; res.data.clear();
14 if (n.empty()) n = "0";
15 if (n[0] == '-') res.sign = -1, n = n.substr(1);
16 for (int i = n.size() - 1; i >= 0; i -= intx::dcnt) {
17 unsigned int digit = 0;
18 for (int j = intx::dcnt - 1; j >= 0; j--) {
19 int idx = i - j;
20 if (idx < 0) continue;
21 digit = digit * 10 + (n[idx] - '0'); }
22 res.data.push_back(digit); }
23 data = res.data;
24 normalize(res.sign); }
25 intx& normalize(int nsign) {
26 if (data.empty()) data.push_back(0);
27 for (int i = data.size() - 1; i > 0 && data[i] == 0; i--)

Callers

nothing calls this directly

Calls 5

normalizeFunction · 0.85
push_backMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected