1. Engineering
  2. Computer Science
  3. 3 15fill in the missing expression in the following c...

Question: 3 15fill in the missing expression in the following c...

Question details

3. 15]Fill in the missing expression in the following C code such that it will return 1 if x isy 0 otherwise (you can assume that neither argument is NaN and that +0.0 and-0.0 are considered equal) int le (float x, float y) unsigned int ux *((unsigned int*) &х); // convert x raw bits un signed int uy = *((unsigned int*) &y); // convert y raw bits un signed int sx = ux >> 31; // extract sign bit of ux unsigned int syuy > 31 // extract sign bit of uy ux <<1i // drop sign bit of ux uy<<1i // drop sign bit of uy // TODO: return using sx, sy, ux, uy Here are some test runs: le (0.0f, 0.0f): 1 le (-0.Of, 0.Of) 1 le (-1.Of, -1.0f): 1 le (1.0f, 1.0f) 1 le (-1.Of, 0.0f) 1 le (0.0f, 1.0f) 1 le (1.0f, 0.0f) 0 le (0.0f, -1.0f) 0 Use only bitwise, logical, and relational ,,<, <-, >, ) operators; no if statements, loops, or arithmetic operators (+,-, *, /, %). Also write a main() function to test your function. Hint: youre going to want to or together all of the cases in which the function will return 1 For example, (ux0 && uy0) will be true only if x is either +0.0f or -0.0f and y is either +0.0f or-0.0f Name your source file 2-3.c

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution