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

x
?
Solved

high-Low-Bit Shifting

Posted on 2003-12-11
5
Medium Priority
?
399 Views
Last Modified: 2010-05-18
Hi,

I have 3 bytes, a,b and c.

a= byte 1: contains high 8 bits of a
b= byte 2: contains high 8 bits of b
c= byte 3: contains 4 bits low(for byte 1) and 4bits low (for byte 2)

i want to take the first 4 bits of c and insert them in the low of a .So result should be

a= {lo 4 bits  of c}{high 8 bits of a} = 12 bits;

thanks
0
Comment
Question by:XPUSR
[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
  • 3
  • 2
5 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 300 total points
ID: 9919750
Hi XPUSR,

lo 4 bits of c
c & 0x15

a anyway has 8 bits
a= {lo 4 bits  of c}{high 8 bits of a}

((c & 0x15 ) <<8) | a

to get

Cheers!
Sunny:o)
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 75 total points
ID: 9921088
Sunny, I confess that I don't know which language this is, but doesn't 0x usually precede a hexadecimal value?

So you meant 15 decimal or 0x0F

?

Just checking ;-)
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9925928
>but doesn't 0x usually precede a hexadecimal value?

>So you meant 15 decimal or 0x0F
yes ... you are right :o)

May be I was in too much hurry when I typed the response

modified response

 Comment from sunnycoder
Date: 12/11/2003 06:11PM IST
 Your Comment  

Hi XPUSR,

lo 4 bits of c
c & 0x0F

a anyway has 8 bits
a= {lo 4 bits  of c}{high 8 bits of a}

((c & 0x0F ) <<8) | a
 
 thanks jimmack
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9925934
LOL ... looks like I copied too much from the post

I am becoming absent minded :o(
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9927510
;-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
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…
Six Sigma Control Plans

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