Write a short function called halfmask as follows:
unsigned int halfmask(unsigned int i); This function sets to 0 all the bits of i except the least significant 16 bits and returns the updated value of i. The least significant 16 bits are untouched.
For example, if this is called as halfmask(0xffffffff) it should return 0xffff (i.e. 65535), and if it is called as thirdbit(0x11111) it should return 0x1111 (i.e. 4369).
Also, your submission should contain just this function and nothing else.
User contributions licensed under CC BY-SA 3.0