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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top