Levent Tulun
Levent Tulun

Reputation: 711

Convert Str (hex int) to Dec Int

I have a hexadecimal string value. I want to convert it to an integer.

function HexStrToInt(const str: string): Integer;
begin
  Result := ??;
end;

such that HexStrToInt('22'), for example, returns 34.

Upvotes: 8

Views: 21536

Answers (1)

David Heffernan
David Heffernan

Reputation: 613582

Perhaps the simplest is to do this:

function HexStrToInt(const str: string): Integer;
begin
  Result := StrToInt('$' + str);
end;

Upvotes: 30

Related Questions