Hex to int

D3us
D3us used Ask the Experts™
on
How to convert a Hex to an Int ?
Int to Hex is just easy, with the IntToHex function, but how do it the other way round ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Hi,

Fast implemantation of hextoint

------------
function HexToInt(s:string):Integer;
const hexvals:string[16]='0123456789ABCDEF';
var i:Integer;
begin
  result:=0;
  s:=uppercase(s);
  for i:=1 to length(s) do
  begin
    result:=result+pos(copy(s,i,1),hexvals)-1;
    if i<>length(s) then
    result:=result shl 4;
  end;
end;

Commented:
Hi D3us

Function HexToInt ( S:String):Integer;
Begin
  Result := StrToInt ( '$'+ S );
End;

good luck

Cesario
D3us:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial