function HexaToDecimal(Hexa:string):longint;
const
ValoresHexa : array['A'..'F'] of integer = (10,11,12,13,14,15);
var
nDecimal : longint;
nIndex : byte;
begin
nDecimal := 0;
Hexa := Uppercase(Hexa);
for nIndex := Length(Hexa) downto 1 do
if Hexa[nIndex] in ['0'..'9']
then nDecimal := nDecimal + StrToInt(Hexa[nIndex]) *
Trunc(Exp((Length(Hexa)-nIndex)*ln(16)))
else nDecimal := nDecimal + ValoresHexa[Hexa[nIndex]] *
Trunc(Exp((Length(Hexa)-nIndex)*ln(16)));
HexaToDecimal := nDecimal;
end;
转载于:https://www.cnblogs.com/myamanda/articles/1539385.html