我有Delphi的,估计BCB应该也一样:
function HexToInt(const asHex: string;
aiDefault: Integer): Integer;
begin
Result := StrToIntDef('$' + asHex, aiDefault);
end;
function IntToBinX(const aiDec: Integer;
abWithLeadingZero: Boolean = False): string;
begin
Result := IntToBin(aiDec);
//IdGlobal.pas is necessary here.
if abWithLeadingZero then
Exit;
while (Length(Result) > 1) and (Result[1] = '0')do
begin
Delete(Result, 1, 1 );
end;
end;
ledtHex.Text := Format('%x', [iASCii])
function BinToInt(asBin: string): LongInt;
var
i: Integer;
begin
Result := 0;
for i := 1 to Length(asBin)do
begin
Result := Result shl 1;
if asBin = '1' then
begin
Result := Result + 1;
end;
end;
end;