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

x
?
Solved

high-Low-Bit Shifting

Posted on 2003-12-11
5
Medium Priority
?
400 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
  • 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

Technology Partners: 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

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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…
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…

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