|
A 16-bit binary number consisting of two bytes, with the most significant bit being the sign bit.
pVal [1] high byte pVal [0] low byte How do I convert this 16-bit binary number?
short CMainFrame :: Get2RealVal (BYTE * pVal)
{
short Val = 0;
if (pVal [1]&0x80 == 0)
{
Val = pVal [1] * 256 + pVal [0];
}
else
{
Val = pVal [1] * 256 + pVal [0];
Val = Val ^ 0xffff + 1;
}
Ranch
return Val;
}
Is there anything wrong with this? |
|