Reputation: 67
if I've a ushort variable which is 0xFFAA and I'll left shift this with 8 bits, I'll get an integer not an unsigned short, why? Here a picture to make you more clear, what I mean:
Is there a way to get from this left shift a 16 bit variable without casting the int into an unsigned short?
Upvotes: 1
Views: 998
Reputation: 24427
If you want to make sure that only the lower 16 bits of a variable are set, you can mask with 0xFFFF
using logical AND:
var supposed = (test << 8) & 0xFFFF;
Upvotes: 1