Sum of Two Integers (Bitwise)
Easy
basics
math
bitwise
Description
Write a function that takes two integer inputs, `a` and `b`, and returns their sum without using the standard '+' or '-' operators. The solution must use bitwise operations.
Examples
Example1:
Input: a = 5, b = 3
Output: 8
Explanation: XOR finds the sum without carry, AND finds the carry, and the loop repeats until the carry is 0.
Example2:
Input: a = -10, b = 5
Output: -5
Constraints
- -1000 <= a, b <= 1000
- No use of '+' or '-' operators.
- Solve using bitwise operations.
Loading...
Test Case 1
Input: 5,3
Output: 8
Test Case 2
Input: 2,12
Output: 14
Test Case 3
Input: -10,5
Output: -5
