Delphi实现把10进制转换成16进制的函数进制转化
2013-04-15 14:21:22 来源:WEB开发网核心提示:constcBitStrings: array[0..7] of string =('000', '001', '010', '011','100', '101', '110
const
cBitStrings: array[0..7] of string =
(
'000', '001', '010', '011',
'100', '101', '110', '111'
);
var
i,j: Integer;
begin
Result := '';
for I := 1 to Length(o) do
begin
j:=strtoint(o[i]);
Result := Result + cBitStrings[j];
end;
while Pos('0', Result) = 1 do Delete(Result, 1, 1);
end;
function TConversion.OtoHexStr(O: string): string;
begin
Result :=BitStrToHextStr(OtoBitStr(o));
end;
cBitStrings: array[0..7] of string =
(
'000', '001', '010', '011',
'100', '101', '110', '111'
);
var
i,j: Integer;
begin
Result := '';
for I := 1 to Length(o) do
begin
j:=strtoint(o[i]);
Result := Result + cBitStrings[j];
end;
while Pos('0', Result) = 1 do Delete(Result, 1, 1);
end;
function TConversion.OtoHexStr(O: string): string;
begin
Result :=BitStrToHextStr(OtoBitStr(o));
end;
function TConversion.OtoIntStr(O: string): string;
begin
Result := OToIntStr(OtoBitStr(o));
end;
end.
更多精彩
赞助商链接