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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstoff,
0bprefix 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:which would be evaluated to 1 if bit 3 is set and 0 if bit 3 is not set.