-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Closed
Description
Is your feature request related to a problem? Please describe.
It is not related to a problem. I want to add an algorithm to add two integers without using addition or subtraction operators. It can be done with Bit Manipulation.
Describe the solution you'd like
Add the 0+1 and 1+0 with XOR and to handle carry we perform a bitwise AND of two 1+1, left shift bit by one place then continue the addition of carry to the sum.
Describe alternatives you've considered
We can also use ++ and -- operators in a loop.
Additional context
None
Test Cases
Input: a=1 b= 2
Output: 3
Input: a=2 b= 3
Output: 5
I want to contribute this to the Math section of theAlgorithms. @siriak @yanglbme
siriak
Metadata
Metadata
Assignees
Labels
No labels