function Int2Hex(Value: Integer): string;
var
iTemp: Integer;
i: Integer;
begin
Result := '';
i := 0;
while i<4 do
begin
case i of
0: iTemp := Value shr 24 and $FF;
1: iTemp := Value shr 16 and $FF;
2: iTemp := Value shr 8 and $FF;
3: iTemp := Value and $FF;
end;
if not Boolean(iTemp) then Result := Result + '00'
else begin
Result := Result + HexArr[iTemp div 16];
Result := Result + HexArr[iTemp mod 16];
end;
Inc(i);
end;
end;
测试:ShowMessage(Int2Hex(-1)); //显示FFFFFFFF
ShowMessage(Int2Hex(MAXINT)); //显示7FFFFFFF
希望大家多提意见,个人觉得挺简洁明了了,呵呵,很明显每步在做什么
新闻热点
疑难解答