inttohex... and HEXTOINT ?????

well, the tittle says it all.. is there a function like hextoint ?
I use Dekphi 3

thanks
LVL 3
bryan7Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

simonetCommented:
function HexToInt(HexStr : string) : cardinal;
begin
  if HexStr[1]<>'$' then
     HexStr := '$' + HexStr;
  Result := StrToInt(HexStr);
end;

function IntToHex(AInt : cardinal) : string;
begin
  Result := Format('%x', [AInt]);
end;


Yours,

Alex

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
scrapdogCommented:
>Result := StrToInt(HexStr);

I never knew that worked with hex...you learn something new everyday...
0
rwilson032697Commented:
From the Delphi 4 help: (not sure it it is also in D3...)

IntToHex returns the hex representation of an integer.

Unit

SysUtils

Category

numeric formatting routines

function IntToHex(Value: Integer; Digits: Integer): string;
function IntToHex(Value: Int64; Digits: Integer): string; overload;

Description

The IntToHex function converts a number into a string containing the number's hexadecimal (base 16) representation. Value is the number to convert. Digits indicates the minimum number of hexadecimal digits to return.

Cheers,

Raymond.
0
bryan7Author Commented:
hey.. excellent answer Alex.. thanks !
rwilson.. thanks for your time too.. I already knew about InttoHex.. i wanted the inverse function.

btw.. alex.. where do ya live in brasil ? I've been to Rio and Sao Paulo's airports in november... !
0
simonetCommented:
Thanks, Bryan.

I live in Belo Horizonte, Brazil 3rd largest city (after São Paulo and Rio). Belo Horizonte is 490 km North from São Paulo and 580 km East from Rio de Janeiro. It's in the state of Minas Gerais.

It's located between mountains, at 770m from the Ocean level. That makes it a very plesant city to live in. It's not as violent as Rio or SP, climate is excellent (a little rainy lately, 'though).

Next time stop by, Bryan!

Alex
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.