Given a sixteen bit number. How can sixth bit can be set to 1 irrespective of its initial value and sixth bit reset to zero irrespective of its initial value
Given a sixteen bit number. How can sixth bit can be set to 1 irrespective of its initial value and sixth bit reset to zero irrespective of its initial value
suppose 'a' contains 16 bit number. And initialize b with 32.
a=a|b; /*this will convert 6th bit to One irrespective of its original bit*/
now for making 6th bit 0, load b with 65503 and do the following.
a=a&b;
for setting the 6th bit:
x | (1<<5)
for unsetting the 6th bit:
x & (~(1<<5))
hope it helps.
what the hell is the answr..