Thema: Dec to Hex

Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#9

Re: Dec to Hex

  Alt 11. Aug 2008, 10:21
Label1.Caption := FloatToHex(123.344)
Delphi-Quellcode:
function FloatToHex(const x: double): string;
type
  tBA = array [0..SizeOf(x)-1] of byte;
var
  Buf: tBA; i: integer;
begin
  For i := 0 to high(tBA)
    do Buf[high(tBA)-i] := tBA(x)[i];
  If (Buf[0] and $80) = 0 {Modif 2007-08-18 by JFH}
    then Buf[0] := Buf[0] xor $80
    else for i := 0 to high(tBA) do Buf[i] := not Buf[i];
  SetLength(Result,SizeOf(Buf)*2);
  BinToHex(@Buf,PChar(Result),SizeOf(Buf));
end;
Thomas
  Mit Zitat antworten Zitat