C++ || Explanation || Keeping it simple || 0ms Faster than 100%
Problem \n> Given two integers a and b, return the sum of the two integers without using the operators + and -.\n\nCan\'t use + or -, fine! We will go old schoo
> #### Problem \n> Given two integers a and b, return the sum of the two integers without using the operators + and -.\n\nCan\'t use `+` or `-`, fine! We will go old school. \nMachines have everything binary, they don\'t have leverage of using these operators. So how they do it? ..... By **Bit Manipulation**\nMachines operate on every bit of both integers and calculate their bit by bit result. So let\'s see how they actually "add" two bits:\n![image](https://assets.leetcode.com/users/images/68ba4a03-5a55-4273-9f2d-b781bb52b672_1661977803.5768507.png)\n\n\nA good observation will reveal that sum here is nothing but bitwise **XOR** and carry is bitwise **AND**.\nThis is good. We have calculated our first result bit. Now for next bit we need to add bits from **a**, **b** & **carry** (carry of our previous addition). How would we add three bits now? \nLet\'s observe again how machines do it.\n![image](https://assets.leetcode.com/users/images/778220f3-6cd1-4aae-bb80-adb439c84b00_1661978389.1628165.png)\n\nHere sum is **XOR** of the three operands, but the carry bit in result is little twisted. It is `=1` only when operands have 2 or more set bits. Which can be formulated as `result carry bit = x\u22C5y + y\u22C5c + c\u22C5x`, where x and y are respective bits of integers `a` and `b`, and c is prev carry bit, our third operand.\n\nNow, we have our formulas in place let\'s jot them down in code.\n<iframe src="https://leetcode.com/playground/L9vwLRTw/shared" frameBorder="0" width="600" height="300"></iframe>\n\n**Notes:**\n1. Right shifting integers `a`  and `b` because we have to access integer bit-by-bit.\n2. The `carry` variable in my code is reused as `prev carry bit` in next operation.\n3. The loop runs 32 times, because given integer limit works with 32 bit sized integers. You can change it accordingly.  \n\nThanks!
['Bit Manipulation', 'C', 'C++']