Last 16 bits

  • Thread starter Thread starter Drew
  • Start date Start date
D

Drew

How do I get the "last 16 bits" from a 32 bit integer using C#?

(I guess this means the right most 16 bits?)

Regards,

Drew
 
Drew said:
How do I get the "last 16 bits" from a 32 bit integer using C#?

(I guess this means the right most 16 bits?)

Regards,

Drew
BitConverter.GetBytes(int32)

Will return an array of 4 bytes.
 
Drew said:
How do I get the "last 16 bits" from a 32 bit integer using C#?

(I guess this means the right most 16 bits?)

Well, if you mean the least significant ones:

int x = y & 0xffff;
 
Back
Top