允许 delphi 在变量中使用 0x56。除了将 Hex 转换成其他东西外,我似乎在互联网上找不到任何东西
Allow delphi to use 0x56 in a variable. I can't seem to find anything on the internet other than converting Hex into something else
我需要能够将 0x56 放入变量中,但出于某种原因,我只能找到将十六进制转换为整数等内容。
十六进制表示法只是一种表示数字的方式。参见 Numerals。
在 Delphi 中,您可以使用 $
前缀将十六进制值分配给数字。
也可以使用 0x
前缀将文本字符串转换为数字。 SysUtils.StrToInt
请查看下面的示例程序以掌握它:
program Project174;
{$APPTYPE CONSOLE}
uses
System.SysUtils;
var
X: Integer;
begin
x := ; // Hex notation (base 16)
WriteLn(x); // Writes 86
x := StrToInt('0x56');
WriteLn(x); // Writes 86
x := StrToInt('');
WriteLn(x); // Writes 86
X := 86; // Decimal notation (base 10)
WriteLn(X); // Writes 86
ReadLn;
end.
我需要能够将 0x56 放入变量中,但出于某种原因,我只能找到将十六进制转换为整数等内容。
十六进制表示法只是一种表示数字的方式。参见 Numerals。
在 Delphi 中,您可以使用 $
前缀将十六进制值分配给数字。
也可以使用 0x
前缀将文本字符串转换为数字。 SysUtils.StrToInt
请查看下面的示例程序以掌握它:
program Project174;
{$APPTYPE CONSOLE}
uses
System.SysUtils;
var
X: Integer;
begin
x := ; // Hex notation (base 16)
WriteLn(x); // Writes 86
x := StrToInt('0x56');
WriteLn(x); // Writes 86
x := StrToInt('');
WriteLn(x); // Writes 86
X := 86; // Decimal notation (base 10)
WriteLn(X); // Writes 86
ReadLn;
end.