Solved

extract a byte

Posted on 2012-03-31
1
291 Views
Last Modified: 2012-06-27
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
Comment
Question by:codey-06
1 Comment
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
ID: 37792029
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
When i run adoquery my application freezes 26 166
Problem to page 4 85
What are programming codes and how do they work? 7 94
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question