C - Get a bit from a byte [duplicate]
This question already has answers here : How do I get bit-by-bit data from an integer value in C? (8 answers) Possible Duplicate: how to get bit by bit data from a integer value in c? I have a 8-bit byte and I want to get a bit from this byte, like getByte(0b01001100, 3) = 1 Firstoff, 0b prefix is not C but a GCC extension of C. To get the value of the bit 3 of an uint8_t a , you can use this expression: ((a >> 3) & 0x01) which would be evaluated to 1 if bit 3 is set and 0 if bit 3 is not set. First of all C 0b01... doesn't have binary constants, try using hexadecimal ones. Second: uint8_t