Hi,
I made the changes from int to long for all the needed places, but
it seems that after i've done that, it seem to convert the last 4 HEX
chars, ignoring the first 4!
I followed exactly as per your changes (even cut and paste).
Any idea where i went wrong?
Regards and Thanks!
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Ben
Combee
Sent: Sunday, December 03, 2000 6:40 AM
To: Palm Developer Forum
Subject: Re: Hex to Integer
"Radiosity" <[EMAIL PROTECTED]> wrote in message
news:31906@palm-dev-forum...
>
> Hi,
>
> Someone post this routine below to convert a Hex to an Int. It worked
fine,
> but it seem to convert only the first 4 digits supplied.
>
> Say i wish to convert 35A4E900 , it only converts 35A4. Anyone any idea
> how to get it to convert all 8 chars?
"int" on PalmOS is 16-bits, so that's 4 hex characters. Change the "int"
types to "long", and you should be able to get all 32-bits. Here it is with
the changes already made:
long StrHexToInt(const char* pszHex)
{
long nResult = 0;
for (int i = 0; *pszHex && (i < (sizeof(long) << 1)); i++)
{
nResult <<= 4;
char c = *pszHex++;
if ((c & 0xF0) == 0x30)
nResult |= (c & 0x0F);
else
nResult |= ((c & 0x0F) + 9);
}
return (nResult);
}
--
Ben Combee
Veriprise Wireless <http://www.veriprise.com>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/