Last active
August 26, 2022 21:29
-
-
Save fmelihh/53ebb8f789366610885e712bc02b40a6 to your computer and use it in GitHub Desktop.
Binary Addition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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