Hi,

I would like to do the following:

(i) from a 24bit hexadecimal mask, I would like to know which bit in ON (1).

(ii) from a 16 bit data word I would like to read the 12 bits (starting from LSB) and 13-16 bits separately

How do I do this?

Printable View

- 03-04-2009dsupriyabit manipulation
Hi,

I would like to do the following:

(i) from a 24bit hexadecimal mask, I would like to know which bit in ON (1).

(ii) from a 16 bit data word I would like to read the 12 bits (starting from LSB) and 13-16 bits separately

How do I do this? - 03-04-2009matsp
What DO YOU think?

--

Mats - 03-04-2009nacho4d
for masking bits... why don't use exclusive disjunction? (if c does not implement it it could be easily implemented with logic or "|" and logic and "&" operators)

your could compare your result with something like pow(2,n) to know if right n-most bit is on or not.

Regards - 03-04-2009dsupriya
anybody has a piece of code?

- 03-04-2009iMalc
If you're a beginner then you'll learn more by working out the answer yourself, or at the very least looking it up yourself online.

If not, then you'll already know how to do it.

We don't help people cheat if that's what you're after. - 03-05-2009dsupriya
Thanks!!

But I thought having a piece of simple code to look at is a process of learning and posting a question in a forum is the way to learn from internet.

But anyway, thanks again for redefining "learning" and "cheating".

Be happy always! - 03-05-2009matsp
Right, there was two purposes to my original "what do you think":

1. How much do you actually know about the subject.

2. You need to learn by doing, not by copying.

I may very well be able to post a piece of example code, but without knowing the level of your understanding, the example code may not be meaningful to you.

--

Mats - 03-05-2009Snafuist
- 03-05-2009tabstop