हस्ताक्षरित इनट्स पर शिफ्ट ऑपरेशंस एक हस्ताक्षरित परिणाम क्यों देते हैं, लेकिन छोटे हस्ताक्षरित ऑपरेटरों पर संचालन के परिणामस्वरूप हस्ताक्षरित int होता है?ऑपरेशन के दौरान शिफ्ट ऑपरेशंस हमेशा एक हस्ताक्षरित int क्यों होता है <32 बिट्स
int signedInt = 1;
int shiftedSignedInt = signedInt << 2;
uint unsignedInt = 1;
uint shiftedUnsignedInt = unsignedInt << 2; //OK. unsigned result
short signedShort = 1;
int shiftedsignedShort = signedShort << 2;
ushort unsignedShort = 1;
uint shiftedUnsignedShort = unsignedShort << 2; //CS0266: Can't cast int to uint
sbyte signedByte = 1;
int shiftedSignedByte = signedByte << 2;
byte unsignedByte = 1;
uint shiftedUnsignedByte = unsignedByte << 2; //CS0266: Can't cast int to uint
और अधिक अंतर्दृष्टि के लिए 'uint shiftedUnsignedByte = (uint) unsignedByte << 2U;' जोड़ें। –