5 7
12
void operator_q15_add_without_plus() {
int a = 15;
int b = 27;
cout << "Adding " << a << " and " << b << " without + operator" << endl;
while(b != 0) {
int carry = a & b; // Find carry bits
a = a ^ b; // Sum without carry
b = carry << 1; // Shift carry left
}
cout << "Result: " << a << endl;
}
void operator_q15_add_without_plus() {
int a = 15;
int b = 27;
cout << "Adding " << a << " and " << b << " without + operator" << endl;
while(b != 0) {
int carry = a & b; // Find carry bits
a = a ^ b; // Sum without carry
b = carry << 1; // Shift carry left
}
cout << "Result: " << a << endl;
}