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 are the benefits of organizational structure?
What is a void * in c?
Differentiate between #include<...> and #include '...'
Explain how can I manipulate strings of multibyte characters?
What is data types?
What is the use of f in c?
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
What are the application of void data type in c?
What does 3 periods mean in texting?
Can we assign integer value to char in c?
When should I declare a function?
How many data structures are there in c?
What is pointer to pointer in c with example?
Why is void main used?
What is the time and space complexities of merge sort and when is it preferred over quick sort?