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
Medium Priority
399 Views
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
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
• 3
• 2

LVL 45

Accepted Solution

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

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

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

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

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

I am becoming absent minded :o(
0

LVL 15

Expert Comment

ID: 9927510
;-)
0

## Featured Post

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
###### Suggested Courses
Course of the Month7 days, 10 hours left to enroll