13 bit from sensor to signed decimal

Can someone help me to convert the 13 bits from a sensor to a decimal signed result?
I am receiving 16 bits from an accelerometer (i2c) where the upper 4 bits are sign bits. Is there some function to convert it?

I have no experience with this. I did see something about 2’s complimentary required for signed binary. Do a google search about 16 bits to decimal signed … especially about 2s comp.

local s32 = (s16 << 16) >> 16;

Thanks for the reply!
Yes, I´ve been searching and it´s exactly a 2´s complimentary output.
My data[1] byte is where those sign bits are… so I did the following code to convert it:
local X = (data[1]<<8) | (data[0]); if (data[1] & 0x80){ server.log("negative input... ") X = -((X - 1) ^ 0xFFFF);}

It seems to work (at least the values are making some sense…)
Thanks again!