how to set Nth bit of variable by using MACRO
Answer Posted / sunitha
/* macro to set Nth bit */
#define SET_N_BIT(x,n) x|((~(unsigned)0)>>(8-(n-n-1))<<n);
Try out this . this is optimised version for setting a bit
work for any bit upto 8 bits if u want for 32 bits than
replace 8 with 32.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is structure data type in c?
Explain how can I pad a string to a known length?
explain how do you use macro?
What are pragmas and what are they good for?
diff between exptected result and requirement?
How can I read/write structures from/to data files?
Who invented bcpl language?
Explain spaghetti programming?
Define Spanning-Tree Protocol (STP)
What does %c mean in c?
What is the use of sizeof () in c?
What is structure in c explain with example?
how to construct a simulator keeping the logical boolean gates in c
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
What is preprocessor with example?