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

Differentiate call by value and call by reference?

919


what is recursion in C

1023


Which programming language is best for getting job 2020?

986


How do you use a pointer to a function?

1029


How many levels of indirection in pointers can you have in a single declaration?

1029


What is a structural principle?

1091


what is use of malloc and calloc?

1853


What are dangling pointers in c?

1123


Why is it important to memset a variable, immediately after allocating memory to it ?

2005


I heard that you have to include stdio.h before calling printf. Why?

1010


What are the advantages and disadvantages of c language?

965


What are 'near' and 'far' pointers?

984


What is binary tree in c?

1040


Why c is a mother language?

967


What are the 5 organizational structures?

970