+ 4
Is it possible to add numbers without using "+"?
2 Respostas
+ 18
cout << 1-(-1);
// outputs 2.
+ 4
You can also do it using only bitwise operations like this:
int add(int a, int b){
while(b){
int t = a ^ b;
b = (a & b) << 1;
a = t;
}
return a;
}
^ is binary XOR, & is binary AND and << is binary left shift.