I recently bought some Bluetooth LE Devices and wanted to read the Data coming from them in Unity. The Problem is I used a library that gives me only a byte array. But I need a sbyte Array.
Example output:
83,186,1,3
But I want:
38, -70,1,3
Here is my Code:
int x = 0;
int y = 0;
z = 0;
result = Convert.ToString(bytes[3], 2).PadLeft(8, '0');
Debug.Log("First Conversion:" + result.Remove(0,1) + " Original:" + bytes[3]);
sbyte result1 = sbyte.Parse(result.Remove(0,1));
Debug.Log("Conversion:" + result1 + " Original:" + bytes[3]);
I've tried this for the last 5h. The farthest I've got was an error that said that my number was too small or too large.