Society of Robots - Robot Forum

Software => Software => Topic started by: Razor Concepts on September 19, 2009, 04:18:30 PM

Title: Bit shifting help!
Post by: Razor Concepts on September 19, 2009, 04:18:30 PM
I have a 10 bit number, for example, 1100000101. I want to store it in 8-bit EEPROM so I split that number into the high set and low set.

High set:
0000000011
Low set:
0000000101

How do I combine these two 8 bit numbers into the original 1100000101?

Title: Re: Bit shifting help!
Post by: chelmi on September 19, 2009, 04:58:50 PM
I have a 10 bit number, for example, 1100000101. I want to store it in 8-bit EEPROM so I split that number into the high set and low set.

High set:
0000000011
Low set:
0000000101

How do I combine these two 8 bit numbers into the original 1100000101?


Code: [Select]
uint8_t msb = 0x03;
uint8_t lsb = 0x05;

uint16_t n = (msb << 8) | lsb;