Explain Sign extension

Sign extension: Whenever an integer value from a type with a specific range is stored in a variable with a larger range, Java employs sign extension to determine the resultant value. The most important bit in the original value is employed to fill the extra bits of the novel value. For example, assume a byte variable comprises the bit pattern, 10000000. When this is stored in a short variable, the resultant bit pattern will be 1111111110000000. When the original value is 01000000, the resultant bit pattern will be 0000000001000000.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.