× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Does anyone have a routine handy (or know of an API) that will convert
hex characters to decimal or integer?


After having read the good alternatives given, I still want to provide
another one, pretty simple and useful too:

**************************************************************
D bin2hex PR 10I 0 ExtProc('sprintf')
D hexMap 17A
D fmtStr * Value Options(*String)
D binMap 20U 0 VALUE OPTIONS(*NOPASS)
**
D hex2bin PR 10I 0 ExtProc('sscanf')
D hexMap 17A
D fmtStr * Value Options(*String)
D binMap 20U 0 Options(*NOPASS)
******************************************************

bin2hex takes an unsigned 64-bit integer and will "printf" its hexadecimal
human-readable representation into the hexMap variable.

Usage would be similar to:

bin2hex(cTempBitMap: // variable to receive output including a \x00
'%016llX': // format to print out
bPriBitMap); // 64-bit unsigned variable

On the other hand, the opposite, hex2Bin will scan a human-readable
hexadecimal expression of a 64-bit variable and will convert it into an
unsigned 64-bit integer:

hex2bin(cTempBitMap: // a 17-byte char variable includes a null char
'%016llX': // format to scan
bSecBitMap); // reference (or pointer) to the 64-bit unsigned
integer

Hope this could help anyway.

Javier Sanchez

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.