Hi,
I have two bytes, each in a separate array, which, when together make a 16 bit integer, i some how need to perform a logical bitwise right shift on the 'integer' and then break it up into two bytes again.
is this even possible?
Hi,
I have two bytes, each in a separate array, which, when together make a 16 bit integer, i some how need to perform a logical bitwise right shift on the 'integer' and then break it up into two bytes again.
is this even possible?
What do you mean? Make them into one and then break them up?...
ok, example: resp[16] = 0x5a and resp[17] = 0xcc.
i would love to be able to printf those two array elements to one handy uint16. is this possible?
print to one?
?Code:unsigned short int x; x = resp[16] | (resp[17] << 8);
sorry, i forgot to finish the example
thankyou for you helpCode:resp[16] = 0x5a resp[17] = 0xcc <i dont know what to do> var = 0x5acc
(forget the bitwise right for now...)
yes, read my post above.
sorry, i got confused with my question... : s sorry.
there is one problem, the endianness is swapped
so
resp[16] = 0x5a
resp[17] = 0xcc
x = resp[16] | (resp[17] << 8);
-> x's value is 0xcc5a
why is that?
thanks
because you didn't specify which one would go to the higher bits before I posted that reply.
and if you can't fix it yourself given my code... you are not worth my time.
sorry, swapping resp[16] for resp[17] did work, when i tried it again... must have been a typo.
thankyou for all your help, it is much appreciated
notice how i posted at 10:54 PM, I never read your post before i posted mine...
alright =)