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));
Buf[SizeOf(Buf) - 1] := #0;
Label2.Caption := Format('As text, the binary contents of Pi look like %s', [Buf]);
HexToBin(Buf, @E, SizeOf(Buf) - 1);
Label3.Caption := Format('Back from text to binary,Pi is now %.15f', [E]);
end;
hextobin,bintohex用法
最新推荐文章于 2023-03-21 10:28:57 发布