From f59093935c06c87a7d9d5d73730630f8d5b2b656 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 12 Jun 2018 16:51:59 +1200 Subject: [PATCH] Add examples of ConvertBits transformation --- src/utilstrencodings.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 32c1baef6..37a07ea06 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -133,7 +133,16 @@ bool TimingResistantEqual(const T& a, const T& b) */ bool ParseFixedPoint(const std::string &val, int decimals, int64_t *amount_out); -/** Convert from one power-of-2 number base to another. */ +/** + * Convert from one power-of-2 number base to another. + * + * Examples using ConvertBits<8, 5, true>(): + * 000000 -> 0000000000 + * 202020 -> 0400100200 + * 757575 -> 0e151a170a + * abcdef -> 150f061e1e + * ffffff -> 1f1f1f1f1e + */ template bool ConvertBits(const O& outfn, I it, I end) { size_t acc = 0;