IntToHex 10转16,不完善 16转10,没现成的 function HexToInt(Hex:String):integer; var HexDigital:Set of char; i:integer; Digital:string; begin HexDigital:=['1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','a','b','c','d','e','f']; if Length(Hex)=0 then EHexToInt(Hex,EmptyHex); for i:=1 to Length(Hex) do begin Digital:=Copy(Hex,i,1); if (i=1)and(digital='$')then Continue; if not(StrToChar(Digital) in HexDigital) then EHexToInt(Hex,IllegalHex); end; Digital:=Copy(Hex,1,1); if Digital<>'$' then Hex:='$'+Hex; Result:=StrToInt(Hex); end;
[A0][06][C1]=3
[7E][EB][CD]=1 10100000
00000110
11000010
0011001010100000
00000110
11000001
0011010001011110
11101011
11001101
00110010看了3组,没看出什么,不是每位都有共同算法吧?眼花走人。
10转16,不完善
16转10,没现成的
function HexToInt(Hex:String):integer;
var
HexDigital:Set of char;
i:integer;
Digital:string;
begin
HexDigital:=['1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','a','b','c','d','e','f'];
if Length(Hex)=0 then EHexToInt(Hex,EmptyHex);
for i:=1 to Length(Hex) do begin
Digital:=Copy(Hex,i,1);
if (i=1)and(digital='$')then Continue;
if not(StrToChar(Digital) in HexDigital) then EHexToInt(Hex,IllegalHex);
end;
Digital:=Copy(Hex,1,1);
if Digital<>'$' then Hex:='$'+Hex;
Result:=StrToInt(Hex);
end;
是的,每组都有相同算法的。看看这个:
[D6][6B][F4]=2
[A0][06][C2]=2
C2与F4和一种关系算过后都等于2,我想这种关系就在D6 和6B或者A0和06之间.
这组也一样:
[7E][EB][CD]=1
[A0][06][AF]=1