This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Converting from BCD

So I have to convert a number from BCD, however when I do it like this:

((X>>4)*10) + X&0xF

It comes out a wrong number, however if I do this:

int H = x>>4;
int L = x&0xF;
return H*10 + L;

it goes just right
why is this?

for an example, I converted 16 to BCD(stays 0x16) and when I execute the 1st code it outputs 0