Hacker News new | ask | show | jobs
by mforney 1695 days ago
> A simple way to fix this would be to shift c by 24u, "(c << 24u)" which would promote both values to unsigned int

This works for most arithmetic operators, but not shift: "The type of the result is that of the promoted left operand". The type of the right-hand-side has no effect on the type of the result.

To fix this, you'd need to cast the left-hand-side to a type that is wide enough.