Convert decimal to balanced Heptavintimal
问题 I'm trying to make a function to convert decimal to balanced Heptavintimal (0123456789ABCDEFGHKMNPRTVXZ) where 0 represent -13, D : 0 and Z 13 I have tried this but some cases are not working properly: static const std::string HEPT_CHARS = "0123456789ABCDEFGHKMNPRTVXZ"; std::string heptEnc(int value){ std::string result = ""; do { int pos = value % 27; result = std::string(HEPT_CHARS[(pos + 13)%27] + result); value = value / 27; } while (value != 0); return result; } Here is what I get in