16bit signed integers
Posted: Fri Jan 25, 2013 3:53 pm
While I collect the two data from I2C,
If perform by C, my code is like the following
short a = 0;
short b = 0;
try
{
a = Convert.ToInt16(recvbuf[1] << 8);
b = Convert.ToInt16(recvbuf[2]);
}
catch(Exception err)
{
Debug.Print(err.Message);
}
float c = (a + b) / (float)10;
DCLabel.Text = c.ToString();
however, i cannot see any signed 16bits operation or conversion tools in
ARMbasic.Anybody know How to do the same in ARMbasic.
If perform by C, my code is like the following
short a = 0;
short b = 0;
try
{
a = Convert.ToInt16(recvbuf[1] << 8);
b = Convert.ToInt16(recvbuf[2]);
}
catch(Exception err)
{
Debug.Print(err.Message);
}
float c = (a + b) / (float)10;
DCLabel.Text = c.ToString();
however, i cannot see any signed 16bits operation or conversion tools in
ARMbasic.Anybody know How to do the same in ARMbasic.