Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

extract a byte

Posted on 2012-03-31
1
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

715 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