byte

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
I've a byte value of 15...
i wan to get it's representation a follows
0x01 | 0x02|0x03|0x04


basically i want to know by OR ing which numbers,..am I getting a value of
15...

help me out..
 
AVL said:
I've a byte value of 15...
i wan to get it's representation a follows
0x01 | 0x02|0x03|0x04

basically i want to know by OR ing which numbers,..am I getting a value of
15...

Do you mean

0x01 | 0x02 | 0x04 | 0x08?

If so, you basically want to test a bit at a time, which is easy to do
with a for loop - start with 1, test whether that bit is set using
if ((value & mask) != o)
and then shift the mask left one bit.

Lather, rinse, repeat.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top