Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Sum of Two Integers
Bookmark
Input
Example 1
Example 2
Example 3
Custom
a
=
1
,
b
=
2
7
6
5
4
3
2
1
0
a
= 1
b
= 2
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
7
6
5
4
3
2
1
0
a
= 1
b
= 2
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
7
6
5
4
3
2
1
0
round 1
a
= 1
b
= 2
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
7
6
5
4
3
2
1
0
round 1
a
= 1
b
= 2
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
b =
2
is not 0: keep adding the carry
7
6
5
4
3
2
1
0
round 1
a
= 1
b
= 2
carry
= 0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
carry = (
1
&
2
) << 1 = 0 << 1 =
0
7
6
5
4
3
2
1
0
round 1
a
= 3
b
= 2
carry
= 0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
a = a ^ b =
1
^
2
=
3
7
6
5
4
3
2
1
0
round 1
a
= 3
b
= 0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
b = carry =
0
7
6
5
4
3
2
1
0
a
= 3
b
= 0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1 + 2 = 3
algo
master
.
io
Step:
Add 1 + 2 without the + operator: XOR adds each column without carry, AND shifted left is the carry. Repeat until the carry dies out
0 / 6
Input
Example 1
Example 2
Example 3
Custom
a
=
1
,
b
=
2
0 / 6
algo
master
.
io
Step:
Add 1 + 2 without the + operator: XOR adds each column without carry, AND shifted left is the carry. Repeat until the carry dies out