Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • *** hopes to play with balanced trinary hardware Commented Oct 1 at 3:06
  • 1
    "*subset is expanded to an int when combined with integer constants" No, in the first case it is promoted to an int because a shift operator was used. And the shift operators are a special case since after integer promotion, they do not use "balancing" (aka the usual arithmetic operations) between the operands. Commented Oct 1 at 6:56
  • From a C language perspective, the result does not depend on endianness, so much as it produces undefined behavior as a result of strict aliasing violations associated with evaluating *subset. It is possible to observe endianness effects without engaging UB, but in this case, the endianness effect you describe is directly linked to UB. (And so it could, in principle, not behave as you describe.) Commented Oct 1 at 12:41