Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

/* * w2301 - return 1 if x == y, and 0 otherwise * Examples: w2301(5,5) = 1, w2301(4,5) = 0 * Legal ops: !

/* * w2301 - return 1 if x == y, and 0 otherwise * Examples: w2301(5,5) = 1, w2301(4,5) = 0 * Legal ops: ! ^ * Max ops: 2 * Rating: 2 */ int w2301(int x, int y) { return 2; } /* * w2302 - Check whether x is nonzero * Examples: w2302(3) = 1, w2302(0) = 0 * Legal ops: ~ & | + >> * Max ops: 5 * Rating: 4 */ int w2302(int x) { return 2; } /* * w2303 - if x <= y then return 1, else return 0 * Example: w2303(4,5) = 1. * Legal ops: ! ~ & ^ | + >> * Max ops: 14 * Rating: 3 */ int w2303(int x, int y) { return 2; } /* * w2304 - if x > y then return 1, else return 0 * Example: w2304(4,5) = 0, w2304(5,4) = 1 * Legal ops: ! ~ & ^ | + >> * Max ops: 14 * Rating: 3 */ int w2304(int x, int y) { return 2; } /* * w2305 - return 1 if x < 0, return 0 otherwise * Example: w2305(-1) = 1. * Legal ops: & >> * Max ops: 2 * Rating: 2 */ int w2305(int x) { return 2; } /* * w2306 - return 1 if 0x30 <= x <= 0x39 * These are the ASCII codes for characters '0' to '9' * Example: w2306(0x35) = 1. * w2306(0x3a) = 0. * w2306(0x05) = 0. * Legal ops: ! ~ | + >> * Max ops: 9 * Rating: 3 */ int w2306(int x) { return 2; } /* * w2307 - return 1 if x can be represented as a * 16-bit, two's complement integer. * Examples: w2307(33000) = 0, w2307(-32768) = 1 * Legal ops: ! ^ >> * Max ops: 4 * Rating: 1 */ int w2307(int x) { return 2; } /* * w2308 - return x -> y in propositional logic - 0 for false, 1 * for true. (->) is called implication in propositional logic * A -> B is false when A is true and B is false, * and it is true in all other cases. * Example: w2308(1,1) = 1 * w2308(1,0) = 0 * Legal ops: ! ~ ^ | * Max ops: 4 * Rating: 2 */ int w2308(int x, int y) { return 2; } /* * w2309 - Return bit-level equivalent of expression (int) f * for floating point argument f. * Argument is passed as unsigned int, but * it is to be interpreted as the bit-level representation of a * single-precision floating point value. * Anything out of range (including NaN and infinity) should return * 0x80000000u. * Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while * Max ops: 16 * Rating: 4 */ int w2309(unsigned uf) { return 2; } /* * w2310 - return floor(log base 2 of x), where x > 0 * Example: w2310(16) = 4 * Legal ops: ! ~ & ^ | + << >> * Max ops: 48 * Rating: 4 */ int w2310(int x) { return 2; } /* * w2311 - Extract byte n from word x * Bytes numbered from 0 (LSB) to 3 (MSB) * Examples: w2311(0x12345678,1) = 0x56 * Legal ops: & << >> * Max ops: 3 * Rating: 2 */ int w2311(int x, int n) { return 2; } /* * w2312 - Return bit-level equivalent of absolute value of f for * floating point argument f. * Both the argument and result are passed as unsigned int's, but * they are to be interpreted as the bit-level representations of * single-precision floating point values. * When argument is NaN, return argument.. * Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while * Max ops: 6 * Rating: 2 */ unsigned w2312(unsigned uf) { return 2; } /* * w2313 - return a mask that marks the position of the * most significant 1 bit. If x == 0, return 0 * Example: w2313(96) = 0x40 * Legal ops: ! ~ & ^ | + << >> * Max ops: 16 * Rating: 4 */ int w2313(int x) { return 2; } /* * w2314 - Return bit-level equivalent of expression -f for * floating point argument f. * Both the argument and result are passed as unsigned int's, but * they are to be interpreted as the bit-level representations of * single-precision floating point values. * When argument is NaN, return argument. * Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while * Max ops: 8 * Rating: 2 */ unsigned w2314(unsigned uf) { return 2; } /* * w2315 - return word with all odd-numbered bits set to 1 * Legal ops: | << * Max ops: 6 * Rating: 2 */ int w2315(void) { return 2; } /* * w2316 - if x < y then return 1, else return 0 * Example: w2316(4,5) = 1. * Legal ops: ! ~ & ^ | + >> * Max ops: 13 * Rating: 3 */ int w2316(int x, int y) { return 2; } /* * w2317 - return 1 if x >= 0, return 0 otherwise * Example: w2317(-1) = 0. w2317(0) = 1. * Legal ops: ~ & >> * Max ops: 3 * Rating: 3 */ int w2317(int x) { return 2;

answers need to follow the max ops rules!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions