C++ algorithms for generating binary digits from a decimal input