Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Double aus Bytes erstellen (https://www.delphipraxis.net/95814-double-aus-bytes-erstellen.html)

Dawn87 13. Jul 2007 14:48


Double aus Bytes erstellen
 
Hallo,

ich habe ein Array mit 8 Byte, wie kann ich diese in einen Double verwandeln? Dieser Double wurde voher auf einem Mikrocontroller auseinandergenommen um in über die serielle Schnittstelle übertragen zu können.

Grüße
Stefan

sniper_w 13. Jul 2007 15:23

Re: Double aus Bytes erstellen
 
Delphi-Quellcode:
var
  ar: array[0..7]of Byte;
  db: PDouble;
  myDouble: Double;
begin
  db := PDouble(@ar[0]);
  myDouble := db^;
end;
oder über "unions" in c style
Delphi-Quellcode:
type TMultiType = packed record
  case Boolean of
  true: (as_array: array[0..7]of Byte);
  false: (as_double: Double);
end;

Dawn87 13. Jul 2007 15:53

Re: Double aus Bytes erstellen
 
Danke! Funktioniert

Grüße
Stefan


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:21 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz