Announcement

Collapse
No announcement yet.

Typumwandlung von INT-Array nach Float

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Typumwandlung von INT-Array nach Float

    Hallo,

    ich habe folgendes Problem: Ich steuere ein Gerät über Delphi an (RS-232) und bekomme die Daten als Byte-Puffer. Die Definition der Daten ist wie folgt:

    int temp[4];
    temp[0] = the 1st Byte;
    temp[1] = the second Byte;
    temp[2] = the third Byte;
    temp[3] = the fourth Byte;
    double result=(temp[3]*0x100*0x100*0x100+temp[2]*0x100*0x100+temp[1]*0x100+temp[0]+100000)/2;

    Wenn ich das ganze in Delphi umsetze sieht das folgendermaßen aus:


    iArray[1]:= Byte(RxStr[1]);
    iArray[2]:= Byte(RxStr[2]);
    iArray[3]:= Byte(RxStr[3]);
    iArray[4]:= Byte(RxStr[4]);
    value := (IArray[4]*$100*$100*$100+IArray[3]*$100*$100+IArray[2]*$100+IArray[1]+100000)/2;

    wobei RxStr der RS-232 Recive-Puffer ist (String). Allerdings scheint Delphi die 4 Bytes nicht korrekt in einen Single umzuwandeln.

    Wer hatte eine Idee ?


    MfG

    Frank
Working...
X