Step 1: Define a lookup table containing the permissions of the two in row format:
const char * const powers_of_two[] = {"1", "2", "4", "8", "16", "32", "64", ...};
Step 2: Write a function that adds two numbers to the string format.
Step 3: Iterate over the bits of your number and add all the lines corresponding to 1 bit.
Step 4. Print the result.
I myself used this approach to print very large floating point numbers, and it worked fine for me.
source
share