shifting in arrays elements

i have data_word = {0x63};

I want data_word_lsb = 3; // got incorrect value "0x30" instead of "3"
data_word_msb = 6; //got right value "6" in following way

1
2
3
4
unsigned int data_word[1]; 
unsigned int data_word_lsb = data_word[0]<<4;
unsigned int data_word_msb = data_word[0]>>4;


How i would get the right value of data_word_lsb?
Last edited on
How i would get the right value of data_word_lsb?
you need to mask out the lsb. Shifting is not appropriate:

unsigned int data_word_lsb = data_word[0] & 0x0f; // masking the lower 4 bits
thanks coder777
Topic archived. No new replies allowed.