0

I am shifting in 3 chars from serial port every 3rd char is a double that i split up for the port, so now i need to put it back to gether.

(Value before sending = 0x3F3400 or 0.703125)

char[0] = 0x3F  (msb)
char[1] = 0x34
char[2] = 0x00  (lsb)

double total = (char[0] << 16)+(char[1] << 8)+(char[2]); // this part did not work

Pls advise how to rebuild this, I dont understand doubles well enough, I cannot even tell which part of a double is the decimal point or - sign thanks!

doggy
  • 75
  • 1
  • 8

1 Answers1

1

I can't get yor value, but as help can advice you to use BitConverter and byte array like this:

var v = new byte[8];
v[7] = 0x3F;
v[6] = 0x34;
v[5] = 0x00;
double total = BitConverter.ToDouble(v, 0);
Console.WriteLine(total.ToString("0.0000000000000"));
Backs
  • 24,430
  • 5
  • 58
  • 85
  • close but, idk why values are being thrown off like that, also it seems the double in the microchip is 24-bit, trying now to dig for more details – doggy Sep 27 '15 at 15:40