??? 08/25/12 17:18 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#188167 - Setting & clearing bits Responding to: ???'s previous message |
#define MASK 0x10 some_value |= MASK; // Set only the '1' bits in MASK some_value &= ~MASK; // Clear only the '1' bits in MASKThus you only need one MASK definition to allow both setting & clearing the particular set of bits. Further, some_value |= ~MASK; // Set all bits except the '1' bits in MASK some_value &= MASK; // Clear all bits except the '1' bits in MASK Raghunathan said:
spare a thought that there could be novices also and for whom c-code is hobby Some essential 'C' references for you: http://blog.antronics.co.uk/2010/12/12 |
Topic | Author | Date |
A simple doubt in C | 01/01/70 00:00 | |
Clears 7 low bits but protects unknown # of high bits | 01/01/70 00:00 | |
Pesrpective... | 01/01/70 00:00 | |
Setting & clearing bits | 01/01/70 00:00 | |
Concept is very clear now... | 01/01/70 00:00 | |
Practical C Programming | 01/01/70 00:00 |