beta.blog

C#: Convert Integer to unsigned 24-bit Integer

by on Aug.04, 2011, under Programming

The following C-Sharp sample code will convert a regular 32-bit Integer to an unsigned 24-bit Integer:

byte[] b = BitConverter.GetBytes(i);
uint ret =  (((uint)b[0]) << 16) | (((uint)b[1])<<8) | ((uint)b[2]);

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!