MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / CompressAmount

Function CompressAmount

src/compressor.cpp:150–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148// (this is decodable, as d is in [1-9] and e is in [0-9])
149
150uint64_t CompressAmount(uint64_t n)
151{
152 if (n == 0)
153 return 0;
154 int e = 0;
155 while (((n % 10) == 0) && e < 9) {
156 n /= 10;
157 e++;
158 }
159 if (e < 9) {
160 int d = (n % 10);
161 assert(d >= 1 && d <= 9);
162 n /= 10;
163 return 1 + (n*9 + d - 1)*10 + e;
164 } else {
165 return 1 + (n - 1)*10 + 9;
166 }
167}
168
169uint64_t DecompressAmount(uint64_t x)
170{

Callers 4

SerializationOpMethod · 0.85
TestEncodeFunction · 0.85
TestDecodeFunction · 0.85
TestPairFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestEncodeFunction · 0.68
TestDecodeFunction · 0.68
TestPairFunction · 0.68