Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
Delphi 7 Enterprise
|
Re: HexToBin
19. Sep 2003, 21:25
Hallo,
na das war eine schwere Geburt!
(3 Labels auf die Form)
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
E: Extended;
//Make sure there is room for null terminator
Buf: array[0..SizeOf(Extended) * 2] of Char;
begin
E := Pi;
Label1.Caption := Format('Pi starts off as %.15f', [E]);
BinToHex(@E, Buf, SizeOf(E));
//Slot in the null terminator for the PChar, so we can display it easily
Buf[SizeOf(Buf) - 1] := #0;
Label2.Caption := Format('As text, the binary contents of Pi look like %s', [Buf]);
//Translate just the characters, not the null terminator
HexToBin(Buf, @E, SizeOf(Buf) - 1);
Label3.Caption := Format('Back from text to binary, Pi is now %.15f', [E]);
end;
Quelle: http://delphi.about.com/library/rtl/blrtlHexToBin.htm
Armin P. Pressler
BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
|
|
Zitat
|