Integer to string with radix?

The from_str_radix method perform string to integer convertion for a specific radix, but how to do the opposite, convert a integer into a string with a specific radix ?

For the pre-defined bases of 2, 8, 10, and 16, use the built-in formatting traits: Binary, Octal, Display, LowerHex and UpperHex. For any other base, it's still trivial to roll your own by repeated division and remainder taking.

2 Likes

You could round-trip through BigUint for the general ([2..=36]) case.