1 постов
Bit Shift: define width and sign before judging the result
A shift operation needs an integer, a direction, and a bit-width convention. Test a small positive value, then a value whose leading bit becomes significant. For right shifts, distinguish sign-preserving from zero-filling behavior; for left shifts, decide whether bits beyond the selected width are discarded.
Some runtimes coerce ordinary numbers to 32-bit integers before shifting. If the tool supports another width or arbitrary precision, document that choice. Report input in both decimal and binary, shift count, selected operation, expected bit pattern, and actual value.
·1