Format('Integer %0:d in Hex is %0:.8x', [Value]);
当然,有简单方法我们要用简单方法哦接着介绍自己的方法
var HexArr: array[1..15]of string= ('1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
function Int2Hex(Value: Integer): string;
var
iTemp: Integer;
i: Integer;
begin
Result := '';
i := 0;
while i4 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
希望大家多提意见,个人觉得挺简洁明了了,呵呵,很明显每步在做什么