Skip to content

Instantly share code, notes, and snippets.

@fmelihh
Last active August 26, 2022 21:29
Show Gist options
  • Save fmelihh/53ebb8f789366610885e712bc02b40a6 to your computer and use it in GitHub Desktop.
Save fmelihh/53ebb8f789366610885e712bc02b40a6 to your computer and use it in GitHub Desktop.
Binary Addition
def add_binary(a,b):
total = a + b
bits = []
while total > 0:
remainer = total % 2
total = total // 2
bits.append(str(remainer))
return ''.join(reversed(bits))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment