I have a method where I decode some information from a file, when I attempt to divide the value decoded by 10, let's say, it removes the last digit.
private int DecodeInt(byte[] bytes, int start)
{
int r2 = 0;
byte ch1 = bytes[start];
byte ch2 = bytes[start + 1];
int result = ch2 + (ch1 * 256);
if (result > 32767)
{
r2 = 0;
}
else
{
r2 = result;
}
return r2;
}
I know the value displayed should be 39.5.
Label_1.Text = (DecodeInt(Rec, 22)).ToString(); // Displays 395
Label_1.Text = (DecodeInt(Rec, 22) / 10).ToString(); // Displays 39
I'm confused as to why it doesn't function... I'm sure it will be simple adjustment but it's driving me a little mad.