Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is structure data type in c?

989


Explain how can I pad a string to a known length?

1148


explain how do you use macro?

1114


What are pragmas and what are they good for?

952


diff between exptected result and requirement?

2014


How can I read/write structures from/to data files?

936


Who invented bcpl language?

1140


Explain spaghetti programming?

1204


Define Spanning-Tree Protocol (STP)

1085


What does %c mean in c?

1035


What is the use of sizeof () in c?

1005


What is structure in c explain with example?

1118


how to construct a simulator keeping the logical boolean gates in c

2223


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)

2299


What is preprocessor with example?

1016