This question’s accepted answer shows how to set a bit in c: How do you set, clear, and toggle a single bit?
But it is not really said what ‘x’ is.
Is it counted from left to right or right to left ? Isn’t that platform dependent anyway ?
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.
The C standard doesn’t say how you number the bits you shift. It says that a value will be twice as large for each position you shift it.
On most current machines, this means that
1 << xwill set bit number x in the value’s representation. It formally doesn’t say where that bit is stored.