来源
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/sum-of-two-integers/
描述
不使用运算符 + 和 - ,计算两整数 a 、b 之和。
示例 1:
输入: a = 1, b = 2
输出: 3
题解
class Solution {public int getSum(int a, int b) {while (b != 0) {int carry = a & b;a ^= b;b = carry << 1;}return a;}}
