Possible Duplicate:
c++ template for conversion between decimal and arbitrary base
I would like to convert an instance of unsigned int
to an instance of std::vector<unsigned int>
in base X where X is any number from 2 to maximum number an unsigned int
can represent.
EDIT: I used to say an unsigned int
in base 10, but that got critical comments, and I think that's right, so I removed it to avoid confusion.
There are a lot of questions and answers on SO that cover something like itoa
that converts up to base 16 or 32 or some small number (with this itoa
implementation page being pointed out as good resource). I wasn't able to find a nice conversion for bases much larger than that.
Note: Performance is not a concern (within reason).