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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!