473,408 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

what is masking in c?

i know that it is something related with the bit fields and the i know about the bit operators....but what actually is the masking??
May 22 '07 #1
2 3439
weaknessforcats
9,208 Expert Mod 8TB
A mask is a bit pattern. Suppose you have this pattern of bits in an unsigned char:

11001010

and you want to see if bit 3 is set (that's the 4th bit from the right). So you use a mask:

00001000

and AND the mask with the bit pattern:


11001010
00001000
------------
00001000

If the result of the AND matches the mask, then the 4th bit is set.

And remember: There is no money in bit-fiddling :)
May 22 '07 #2
Savage
1,764 Expert 1GB
A mask is a bit pattern. Suppose you have this pattern of bits in an unsigned char:

11001010

and you want to see if bit 3 is set (that's the 4th bit from the right). So you use a mask:

00001000

and AND the mask with the bit pattern:


11001010
00001000
------------
00001000

If the result of the AND matches the mask, then the 4th bit is set.

And remember: There is no money in bit-fiddling :)
Sayed in simple English:

Mask used with bit operator & is used to pull out from memory word bits that u wish to use.

Mask used with bit operator |(OR) is used to set bit or bits in state 1,independent from they previous state.Thats why we use with it mask that in does positions have value of 1 and in all other value of 0

e.g

0100101010111001
|
0000000000110001
---------------------------
0100101010111001

Mask used with operator ^ has nearly the same tautology as a | operator.Only differance is that when using ^ 1 and 1 will result in 0 and it's well suited to test equality of two different memory words
e.g

0000100111000011
^
0101010010110111
---------------------------
0101111000010100

And last bit operator resembles negation (~)

Savage
May 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Piotr | last post by:
Please help me, I can't solve this problem: I have domain: www.main_domain.com/index.php?userid=23&parametr1=2&parametr2=3 (and other site files like...
2
by: Ginchy | last post by:
I have uploaded a small 3 page web using MS Publisher 2003 and after uploading I switched on url masking to cloak the url. I am certain that it worked fine. I simply changed the colour scheme...
1
by: john sutor | last post by:
Is there a way in C# to add masking (for a date format) to a textbox?
0
by: Dana Epp | last post by:
I have a ToolBarButton that when I set it to disabled (button.Enabled = false;) causes a really ugly gray masking effect to take place. This is normal and the intended way of the button, but I...
1
by: Brian Keating EI9FXB | last post by:
Hello there, Does anyone know how to to Bitmap masking in .NET, In c++ i used, CreateCompatibleDC GetBitmap Then on the bitmap and the bitmap mask i called. {SelectBitmap StretchBlt}
1
by: Klaus Baumgart | last post by:
I try to send an Email by using the submit in a html Formular. The body of the Email should have XML Tags. How can I using masking to get a proper XML-File Klaus <!DOCTYPE HTML PUBLIC...
1
by: hapa | last post by:
how can i use bitwise masking in C++ please explain
3
by: ara | last post by:
Hi, I have got a table which pops up when the pointer is placed over a link,as <div id="metapopup" onMouseOver="showmeta();" onMouseOut="hidemeta();"> <table border="0" cellpadding="5"...
2
by: meghla | last post by:
I can not understand how to implement bit masking on a c code?? while working with array it is taking too much time.................. so i need help. i need some suggestion and sample code of C...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.