Question
You need a code sequence to replace a bit field in a 64 bit long long value. Using little-endian numbering, the field is in bits
You need a code sequence to replace a bit field in a 64 bit long long value. Using little-endian numbering, the field is in bits 48 through 57. You have available a mask (called mask) with ones in exactly bits 48 through 57. Assuming the current long long is in a variable called input, and the new value for the field is in (the low order bits of) a variable called newval, which of these assignments properly updates the bit field?
a.long long output = (input & ~mask) | ((newval << 48) & mask);
b.long long output = (input & mask) | ((newval << 48) & ~mask);
c.long long output = (input | ~mask) & ((newval << 48) & mask);
d.long long output = ((input & ~mask) >> 48 | newval;
e.long long output = (((input & ~mask) >> 48 | newval) << 48;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started