how to separate 1 var into 2 vars?

in new programmer and i got a problem
the problem is that i need to separate 4 digits hex number into 2 bytes(2 digits each) to two different variables, its pretty simple but i still don't know how to do it with C++
example:
lets say i got the decimal number 30,000
in hex its 7530
means the first byte is 75 and the second is 30 (hex values)
now i need to save each of the bytes on different vars, how do i do it?
http://en.wikipedia.org/wiki/Logical_shift
http://en.wikipedia.org/wiki/Bitwise_operation#AND

If I tell you any more, I'd be doing it for you.
One tip I will give you is that you should make sure everything is unsigned when doing bit twiddling.
can you please explain what I have to do? i can't understand what do you want me to do with those things :O
can you give an example how to do it?
Last edited on
30,000 in hex is 7530 and in binary is 01110101 00110000

If you AND 01110101 00110000 with 00000000 11111111 then the result is 00000000 00110000

Next you SHIFT 01110101 00110000 to the RIGHT 8 bits which gives you 00000000 01110101
thanks working!
Topic archived. No new replies allowed.