"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/

Reply via email to