FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms-python/algorithms/bit/add_bitwise_operator.py at master · ivan1911/algorithms-python · GitHub
ivan1911
/
algorithms-python
Public
forked from
keon/algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms-python
/
algorithms
/
bit
/
add_bitwise_operator.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (12 loc) · 283 Bytes
Breadcrumbs
algorithms-python
/
algorithms
/
bit
/
add_bitwise_operator.py
Copy path
File metadata and controls
14 lines (12 loc) · 283 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""
The following code adds two positive integers without using the '+' operator.
The code uses bitwise operations to add two numbers.
Input: 2 3
Output: 5
"""
def
add_bitwise_operator
(
x
,
y
):
while
y
:
carry
=
x
&
y
x
=
x
^
y
y
=
carry
<<
1
return
x
Back
|
FazBrowse Home
|
New Git URL