As are are different binary representation of the numbers (for example, take big/little endian), is this cross-platform:
some_unsigned_type variable = some_number;
// set n-th bit, starting from 1,
// right-to-left (least significant-to most significant)
variable |= ( 1 << ( n - 1 ) );
// clear the same bit:
variable &= ~( 1 << ( n - 1 ) );
In other words, does the compiler always take care of the different binary representation of the unsigned numbers, or it's platform-specific?
And what if variable is signed integral type (for example, int) and its value is
zero
positive
negative?
What does the Standard say about this?
P.S. And, yes, I'm interesting in both - C and C++, please don't tell me they are different languages, because I know this :)
I can paste real example, if needed, but the post will become too long