"The problem is that when I enter digits greater than 16"
You mean when you enter more than 16 digits?
Indeed your code cannot work properly for numbers with more than 15 digits. The problem is that the user is still entering decimal numbers, not binary. So, if the user enters 100, it's the decimal 100 not the binary 100 (decimal 4). Decimals are stored as double precision floating point numbers which due to the way they're stored can't always be stored accurately. For integer anything above flintmax (~ 9e15) may get rounded. That's about 15 digits of precision. The end result is that if enter 1...(15 x 0)...1, it's going to be stored as 1...(15 x 0)...0
If you want to be able to enter binary numbers with 16 or more digits you can't use double. You could ask for the input as a string (use input(prompt, 's') but of course your code has to change to process characters instead of numbers.
Also note that you never check that the number entered is made of valid digits.