Using the following description, please replace the return line in C code; /* * addOK: determine if x+y succeeds without overflow * Examples: * addOK(0x40000000,0x20000000) = 1 * addOK(0x40000000,0x40000000) = 0 * addOK(0x55555555,0x2AAAAAAA) = 1 * addOK(0x55555555,0x2AAAAAAB) = 0 * addOK(0x80000000,0x40000000) = 1 * addOK(0x80000000,0x80000000) = 0 * Legal ops: ! ~ & ^ | + << >> * Max ops: 20 *
Using the following description, please replace the return line in C code; /* * addOK: determine if x+y succeeds without overflow * Examples: * addOK(0x40000000,0x20000000) = 1 * addOK(0x40000000,0x40000000) = 0 * addOK(0x55555555,0x2AAAAAAA) = 1 * addOK(0x55555555,0x2AAAAAAB) = 0 * addOK(0x80000000,0x40000000) = 1 * addOK(0x80000000,0x80000000) = 0 * Legal ops: ! ~ & ^ | + << >> * Max ops: 20 *
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 1TF
Related questions
Question
Using the following description, please replace the return line in C code;
/*
* addOK: determine if x+y succeeds without overflow
* Examples:
* addOK(0x40000000,0x20000000) = 1
* addOK(0x40000000,0x40000000) = 0
* addOK(0x55555555,0x2AAAAAAA) = 1
* addOK(0x55555555,0x2AAAAAAB) = 0
* addOK(0x80000000,0x40000000) = 1
* addOK(0x80000000,0x80000000) = 0
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 20
*
*/
int addOK(int x, int y) {
return 2
}
You cannot:
1. Use any control constructs such as if, do, while, for, switch, etc.
2. Define or use any macros.
3. Define any additional functions in this file.
4. Call any functions.
5. Use any other operations, such as &&, ||, -, or ?:, not listed in the
the "Legal ops" list for the function.
6. Use any form of casting.
7. Use any data type other than int.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,