Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.


Please wait...

Technical Discussion :: C
Home > Technical Interview Q&A > C > Discussion

10. What is meant by "bit masking"?

Answer:

Bitmasking refers to the technique of representing a subset of a set using bits of a number .
for eg suppose we have n numbers {1,2,3,4,5,6,7,8} in an array

then a bitmask to indicate the subset{2,3,6} of the above set will be a set of binary values like {0,1,1,0,0,1,0,0} where 1 indicates element at ith index belong to set and 0 indicated that it doesnt.

this 0,1 information can also be stored in bits of a number.

for eg consider a number mask=0;

if we want to set the ith bit of mask to 1 we can apply following operation

mask = mask|(1<
where '|' is bitwise or and '<<' is bitwise left shift operator
and the ith bit will become 1 indicating the number is included in the set
similarly to remove a number from the set following operating can be performed
mask = mask^(1< where '^' is bitwise xor operator

Post Your Answer Here:


Post Your Reply Here:

Alert me
q4i-reply-your-answer

Report Error

Please Login First Click Here

Post Your Reply Here:

Alert me
q4i-reply-your-answer

Report Error

Please Login First Click Here