2x 8bit inputs to 1x 16bit value

Hey guys

I have two 8bit (256) inputs and I need to convert them to 16bit (65536)

At first I thought of doing it as in1 * in2 but when in1 is 256 and in2 is 0 it doesn't put out 256 as expected (because 256*0 = 0).

What would be the best way of doing this

In the end I want a value from 0 --> 65536 from two 0 --> 256

Thanks

Ian

In the end I want a value from 0 --> 65536 from two 0 --> 256

I hope that you mean from 0 to 65535 and 0 to 255

unsigned int anInteger = (256 * highByte) + lowByte;

UKHeliBob:
I hope that you mean from 0 to 65535 and 0 to 255

unsigned int anInteger = (256 * highByte) + lowByte;

Thanks It works :slight_smile:

With this kind of fiddling, you'd usually use a left-shift and bitwise OR

unsigned int anInteger = (highByte << 8) | lowByte;