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 ?
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 ?
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.
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 x 2E2, [...].
On most current machines, this means that 1 << x
will set bit number x in the value's representation. It formally doesn't say where that bit is stored.