Bit Operations using Structure !!!
- To pack Several data objects in the single memory word , Bits are used .
- Flags can be In order to store the Boolean values ( T / F ).
- Eg. Gender of Person can be stored as [M/F] .
- By Setting the flag bit 1 we can set Gender as "Male" and "Female" by setting bit as 0
- A method to define a structure of packed information is known as bit fields.
How to access the Individual Bits ?struct databits { int b1 : 1; int b2 : 1; int b3 : 1; int b4 : 4; int b5 : 9; }data1;
data1.b1 data1.b2 data1.b3 data1.b4 data1.b5
How to initialize Structure ?
Initialized Result -struct databits { - - - - - - }data1 = { 1,1,0,10,234 };
Diagram :data1.b1 = 1 data1.b2 = 1 data1.b3 = 0 data1.b4 = 10 data1.b5 = 234


0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email