3. Consider the following function, which is supposed to add integers between 0 and 15, inclusive, without using the usual arithmetic operators. The problem is to determine what operators should replace [a b and [c. The idea of the algorithm is to first find the result of adding x and y without carries, and separately compute the carry bits. We repeat the process four times in total, replacing x and y with the sum without carries and the carry bits, respectively. Finally, we add x and y without carry (actually, the carry will always be 0 anyway) to get the result. For example, 15 + 1 13 + 7 == badd (15, 1) == Ob01111 + Obo0001 -> Ob01110 + ObO0010 -> Ob01100 + Ob00100 -> Ob01000 + ObO1000 -> ObO0000 + Ob10000 -> Ob10000 badd(13, 7) == ObO1101 + Ob00111 -> Ob01010 + ObO1010 -> Ob00000 + Ob10100 -> Ob10100 + Ob00000 -> Ob10100 + Obo0000 -> Ob10100 == 16 == 20 /** Returns the sum X + Y, where 0 <= X, Y <= 15. */ int badd(int x, int y) { int car; car = (x a y) b 1; x = (x C y); y = car; car %3D (x а у) b 1; х (х с у); у 3 сar; car %3D (x a у) b 1; х (x с у); y = car; car %3D (x a у) b| 1; x = (x C y); y = car; return x c] y; a. What is a ? A O & BOI CO* DO « ЕО» b. What is b? A O & BOI CO^ DO « ЕО» c. What is c A O & BOI CO DO « ЕО»»

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
3.
Consider the following function, which is supposed to add integers between
O and 15, inclusive, without using the usual arithmetic operators. The problem is to
determine what operators should replace a b), and c.
The idea of the algorithm is to first find the result of adding x and y without carries,
and separately compute the carry bits. We repeat the process four times in total, replacing
x and y with the sum without carries and the carry bits, respectively. Finally, we add x
and y without carry (actually, the carry will always be 0 anyway) to get the result. For
example,
15 + 1
13 + 7 ==
==
badd (15, 1)
== Ob01111 + Ob00001
badd (13, 7)
оь01101 + 0ь00111
-> Ob01110 + Ob00010
-> Ob01010 + Ob01010
-> оьо1100 + оь00100
Obo0000 + Ob10100
-> Ob01000 + ObO1000
-> Ob00000 + Ob10000
-> Ob10000
-> Ob10100 + Ob00000
-> Ob10100 + Ob00000
Ob10100
== 16
20
/** Returns the sum X + Y, where 0 <= X, Y <= 15. */
int badd (int x, int y) {
int car;
(х а у) Ь 13;
car =
x = (x C y);
y = car;
car = (x a y) b 1;
x = (x cy);
y = car;
car = (x al y) b| 1;
x = (x C y);
y = car;
car = (x a y) b| 1;
x = (x C y);
y = car;
return x c y;
}
a. What is [a?
A O &
BOI
CO*
DO «
E O >>>
b. What is b?
A O &
BOI
CO*
DO «
ЕО»»»
c. What is c?
A O &
BOI
CO*
DO «
ЕО»»
Transcribed Image Text:3. Consider the following function, which is supposed to add integers between O and 15, inclusive, without using the usual arithmetic operators. The problem is to determine what operators should replace a b), and c. The idea of the algorithm is to first find the result of adding x and y without carries, and separately compute the carry bits. We repeat the process four times in total, replacing x and y with the sum without carries and the carry bits, respectively. Finally, we add x and y without carry (actually, the carry will always be 0 anyway) to get the result. For example, 15 + 1 13 + 7 == == badd (15, 1) == Ob01111 + Ob00001 badd (13, 7) оь01101 + 0ь00111 -> Ob01110 + Ob00010 -> Ob01010 + Ob01010 -> оьо1100 + оь00100 Obo0000 + Ob10100 -> Ob01000 + ObO1000 -> Ob00000 + Ob10000 -> Ob10000 -> Ob10100 + Ob00000 -> Ob10100 + Ob00000 Ob10100 == 16 20 /** Returns the sum X + Y, where 0 <= X, Y <= 15. */ int badd (int x, int y) { int car; (х а у) Ь 13; car = x = (x C y); y = car; car = (x a y) b 1; x = (x cy); y = car; car = (x al y) b| 1; x = (x C y); y = car; car = (x a y) b| 1; x = (x C y); y = car; return x c y; } a. What is [a? A O & BOI CO* DO « E O >>> b. What is b? A O & BOI CO* DO « ЕО»»» c. What is c? A O & BOI CO* DO « ЕО»»
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY