Welcome to Dream.In.Code
Become a C# Expert!

Join 150,394 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,035 people online right now. Registration is fast and FREE... Join Now!




separating lower and upper words

 
Reply to this topicStart new topic

separating lower and upper words

killnine
3 Mar, 2008 - 10:56 AM
Post #1

D.I.C Head
**

Joined: 12 Feb, 2007
Posts: 114



Thanked: 5 times
My Contributions
Hey guys,
Not explicitly a C# question, but I am implementing it in C#.

I have an unsigned integer, 65696. What I want to see is the lower word separated from the upper word. I know this value contains

10000000010100000

Now the lower 8-bits equals 160, and thats the value I want. How do I pull this out? This is very simple question, I just dont know how =P *embarrass*. Better said: how do I mask the upper 8 bits?

This post has been edited by killnine: 3 Mar, 2008 - 10:57 AM
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:17 PM
Post #2

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,290



Thanked: 136 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
This... is a job... for Google! Seriously, the first hit has the answer. tongue.gif

User is online!Profile CardPM
+Quote Post

killnine
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:27 PM
Post #3

D.I.C Head
**

Joined: 12 Feb, 2007
Posts: 114



Thanked: 5 times
My Contributions
QUOTE(baavgai @ 3 Mar, 2008 - 01:17 PM) *

This... is a job... for Google! Seriously, the first hit has the answer. tongue.gif



Google what? I never did find it anywhere because I never knew what to search =P. Anyhow, I just figured it out myself after a while, lots of trial and error.


BTW --

If anyone is interested:

CODE

                    uint[] totalValue = tool.claimID.GetListOfECUs(); //
                    int[] upperWord = new int[totalValue.Length];
                    int[] lowerWord = new int[totalValue.Length];

                    //Find the lower and upper word
                    for (int i = 0; i < totalValue.Length; i++)
                    {
                        upperWord[i] = (int) (totalValue[i] >> 16);
                        lowerWord[i] = (int) (totalValue[i]&0xFFFF);
                    }

User is offlineProfile CardPM
+Quote Post

Nykc
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:31 PM
Post #4

That Just Happened!
Group Icon

Joined: 14 Sep, 2007
Posts: 4,509



Thanked: 18 times
Dream Kudos: 275
My Contributions
Google FTW!

cool.gif
User is online!Profile CardPM
+Quote Post

killnine
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:44 PM
Post #5

D.I.C Head
**

Joined: 12 Feb, 2007
Posts: 114



Thanked: 5 times
My Contributions
QUOTE(Nykc @ 3 Mar, 2008 - 01:31 PM) *

Google FTW!

cool.gif



Damnit, google what?
rolleyes.gif
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:54 PM
Post #6

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,290



Thanked: 136 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua, Cheese

My Contributions
QUOTE(killnine @ 3 Mar, 2008 - 03:44 PM) *

Damnit, google what?


Did you click the link?

If you want to cut and paste your own, I used "C# bit manipulation". However, "C# bitwise" will also get your there. Even "C# bit"...

Google is just the biggie, any reasonable search engine should get you there.

User is online!Profile CardPM
+Quote Post

killnine
RE: Separating Lower And Upper Words
3 Mar, 2008 - 12:56 PM
Post #7

D.I.C Head
**

Joined: 12 Feb, 2007
Posts: 114



Thanked: 5 times
My Contributions
QUOTE(baavgai @ 3 Mar, 2008 - 01:54 PM) *

QUOTE(killnine @ 3 Mar, 2008 - 03:44 PM) *

Damnit, google what?


Did you click the link?

If you want to cut and paste your own, I used "C# bit manipulation". However, "C# bitwise" will also get your there. Even "C# bit"...

Google is just the biggie, any reasonable search engine should get you there.



Ah, didn't see that it was a link. I thought it was underlined for accentuation. lol
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:04PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month