MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecompressAmount

Function DecompressAmount

src/compressor.cpp:168–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168uint64_t DecompressAmount(uint64_t x)
169{
170 // x = 0 OR x = 1+10*(9*n + d - 1) + e OR x = 1+10*(n - 1) + 9
171 if (x == 0)
172 return 0;
173 x--;
174 // x = 10*(9*n + d - 1) + e
175 int e = x % 10;
176 x /= 10;
177 uint64_t n = 0;
178 if (e < 9) {
179 // x = 9*n + d - 1
180 int d = (x % 9) + 1;
181 x /= 9;
182 // x = n
183 n = x*10 + d;
184 } else {
185 n = x+1;
186 }
187 while (e) {
188 n *= 10;
189 e--;
190 }
191 return n;
192}

Callers 5

UnserMethod · 0.85
TestEncodeFunction · 0.85
TestDecodeFunction · 0.85
TestPairFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls

no outgoing calls

Tested by 4

TestEncodeFunction · 0.68
TestDecodeFunction · 0.68
TestPairFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68