I have a polynomial class, and its natural representation is its coefficients. If a coefficient is set, then its a 1 for binomial basis, 1 or 2 for trinomial basis, etc. For example, in a binomial basis, X2 + 1 is represented as 101; and in a trinomial basis, 2X2 + 1 is represented as 201.
The class provides an operator<<
overload. Internally, the class represents the coefficients using an integral array. So I should be able to perform:
ostringstream oss;
for (size_t i=0; i<v.size(); i++)
oss << v[i];
The problem I am having is I don't know how to configure the ostream for bases other than 8, 10 and 16. ios_base
provides std::oct
, std::dec
and std::hex
for the popular bases, but I don't see what to use for the less frequently used bases. And pages like C++ Reference on ios_base does not discuss what to use.
How do I use ostream with bases other than 8, 10 and 16?