I have to convert a binary number like for example unsigned int bin_number = 10101010 into its decimal representation (i.e. 170) as quickly as possible? What is the best algorithm?
I have to convert a binary number like for example unsigned int bin_number =
Share
Using templates you can solve this problem at compile-time.
The binary template is instantiated again with a smaller
num, untilnumreaches zero and the specialization is used as a termination condition.Example:
std::cout << binary<10101010>::value;For run-time problem: