Solved

extract a byte

Posted on 2012-03-31
1
289 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now