I am combining a two byte ADC output into a single integer. As I do not do much programming anymore I had to think about how to do this....and a little help from teh internet to jog the memory cells into place.
Two examples were:
int i = ((adc_high_byte & 0xFF) << 8) | (adc_low_byte & 0xFF);
Ok, this one looked familiar from projects past.
But then I see this one:
int i = (adc_high_byte << 8) + adc_low_byte;
Which in theory should give me the same result.
Heres the question(s)
Why do I need to AND the byte against a mask THEN shift left in the first example? THe second one seems far simpler(thus faster).