- Signed numbers are converted to a larger data type using this method
- Add copies of the most significant bit (MSB) to the representation
Example
char x = -56; // 0xC8 -> 0b11001000
short y = (short) x; // 0xFFC8 -> 0b1111111111001000Visual representation
- The following figure shows an example of sign extending from to . ( → word size). Notice that the combined weights of the upper two bits () is , which matches the weight of the sign bit for .
