I have a long and a short
I want the bits from the short to overwrite the low order 16 bits of the long.
Ex (broken into 16bit chunks for readability):
> long = 0xffff 0xffff 0xffff 0xffff
> short= 0x1234
>
> output = (long)0xffff 0xffff 0xffff 0x1234
Note that you must AND the
shortvalue with0xFFFFLhere, otherwise sign extension will cause the code to break (all high bits in the result will be set, regardless of their original value in thelong) if theshortis greater than or equal to0x8000.