Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

extract a byte

Hello

Can someone advise how I can extract the first 8 bits and last 8 bits from a 16 bit integer.

for example decimal 64339 = 11111011 01010011

I need the 1st 8 bits decimal 251 (11111011) and then the last 8 bits decimal 83 (01010011)

Can you give me an example of how to write this in C

Thanks
0
codey-06
Asked:
codey-06
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi Codey,

Just mask them off;

   int  Value, Upper, Lower;

  Value = 64339 ;
  Lower = Value & 0xFF;
  Upper = (Value >> 8) & 0xFF;


Good Luck,
Kent
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now