reading four bits at a time from memory. C#

How do I obtain four bytes from a memory offset. Using C#
 The units are in the high 32 bit integer(at Offset 0574) and the fractions are the low 32 bit integer
(at 0570 Offset in memory).

I guess I need to read an int, a byte from 0570 to --> 0577 and select the first four bits for one and the next four bits for the other.

My problem is how do I select four bits at a time. Is there a data type or do I split up the eight bits.
If so I dont know how ? thx.
Who is Participating?
ravs120499Connect With a Mentor Commented:
Selecting 4 bits from a byte (or any other known length) value is easy:

"right-most" (i.e. least significant) 4 bits = bytevalue & 0xF (as greg young said).
left-most (most significant) 4 bits = bytevalue & 0xF0.

But I did not understand the part about the high-32 and low-32 parts. If the underlying data is in two separate 32-bit slots, why do you need to divide it into 4-bit nibbles?

- Ravs
split up the 8 bits ...

4bits = yourvalue & 0xF;



rigidigitalAuthor Commented:
Look I made error here. Terminology is new however basic. You picked it up, I have confused bits and bytes.  Im trying to sort out electrical probs and just getting confused with programming! The bits I want is more like 4 bytes.
gregoryyoungConnect With a Mentor Commented:
Then just read the memory as an integer ... or if you have it as a long ...

value & 0xFFFFFFFF; //gets low 32 bits

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.