|
|
|
|
|
|
ComputerInfoWeb.com offers tips on
computers, notebooks, repairs, Shopping, Software, Security, Computer Rental , Computer Shopping,
Computer Programming, Computer Networking, Maintenance, Hardware, Internet, Game, Electronics and more.
|
|
|
Computer Algorithm : Bit Manipulation In C |
|
|
|
I use macros to simplify bit setting and I also use macros to test bits in C Language. Here are some examples
#define BIT(x) (1 << (x))
#define SETBITS(x,y) ((x) |= (y))
#define CLEARBITS(x,y) ((x) &= (~(y)))
#define SETBIT(x,y) SETBITS((x), (BIT((y))))
#define CLEARBIT(x,y) CLEARBITS((x), (BIT((y))))
#define BITSET(x,y) ((x) & (BIT(y)))
#define BITCLEAR(x,y) !BITSET((x), (y))
#define BITSSET(x,y) (((x) & (y)) == (y))
#define BITSCLEAR(x,y) (((x) & (y)) == 0)
#define BITVAL(x,y) (((x)>>(y)) & 1)
|
|
|
Other Relevant Articles from this Category:
|
|
|
More Categories:
|
|
|
| |
|
|
|
Copyright © ComputerInfoWeb.com. All Rights Reserved.
|