Skip to content

Commit 1fcfc0a

Browse files
committed
format the code and comments
1 parent d27ce13 commit 1fcfc0a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎bit_manipulation/binary_addition.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ def binary_xor(input1: str, input2: str) -> str:
5757
def addition(number_1: str, number_2: str, number_of_bits: int) -> tuple[str, str]:
5858
"""
5959
return tuple with ('sum','carry')
60-
The number of bits in 'sum' is same as the value of number_of_bits passed to the function.
60+
The number of bits in 'sum' = number_of_bits passed to the function.
6161
(i.e, if number_of_bits = 5, the length of 'sum' will also be 5).
6262
63-
Explanation: The formula of sum and carry for each bit in binary operations are:
63+
Explanation:
64+
The formula of sum and carry for each bit in binary operations are:
6465
carry: C5 C4 C3 C2 C1 C0
6566
number_1: A4 A3 A2 A1 A0
6667
number_2: + B4 B3 B2 B1 B0
@@ -81,7 +82,7 @@ def addition(number_1: str, number_2: str, number_of_bits: int) -> tuple[str, st
8182
.
8283
and so on.
8384
84-
The numbers are reversed so that the individual bits are traversed from right to left.
85+
The numbers are reversed so that individual bits are traversed from R to L.
8586
Finally, the resultant sum is reversed again to retain the original format.
8687
8788
>>> addition('1010','1101', 4)

0 commit comments

Comments
 (0)