Maximum base - 36
string base_num = " " ; while ( num > 0 ) { int dig = int ( num % base ) ; if ( dig < 10 ) base_num += to_string ( dig ) ; else base_num += to_string ( ' A ' + dig - 10 ) ; num /= base ; }