Converting big number to base 24
-
@MartinD
Hi,
It's very basic math:BigIntType x; QString number; while (x != 0) { char reminder = x % 24; x /= 24; number += reminder < 10 ? '0' + reminder : 'A' + reminder - 10; } std::reverse(number.begin(), number.end());
Your number system is bad, chose one that's a power of 2, so you can skip the divisions and use bit-wise operations instead.
Kind regards.
-
I used the class in http://stackoverflow.com/questions/4735622/convert-large-hex-string-to-decimal-string . Nice code, easy to implement base 24 conversions.
-
Boost multiprecision is probably the most ready available bignum library you could use for this task. just use
cpp_int
asBigIntType
in @kshegunov 's algorithm