how to convert a hexadecimal array to its integer equivalent
MorgoZ
Posts: 116
Hi!
I know i must be missing something stupid, but i can´t figure out how to convert a string with hex data to an integer.
I have this:
The "hextoi" function does not help because it uses a string parameter like
nAux = hextoi('0302')
But i have no way to convert the hexadecimal representation in acMessage to its string equivalent... or have i?
Ideas?
Thanx!
I know i must be missing something stupid, but i can´t figure out how to convert a string with hex data to an integer.
I have this:
char acMessage[2] integer nAux acMessage = "$03,$02"and i need nAux to have the decimal format of the hexadecimal number "$03,$02"
The "hextoi" function does not help because it uses a string parameter like
nAux = hextoi('0302')
But i have no way to convert the hexadecimal representation in acMessage to its string equivalent... or have i?
Ideas?
Thanx!
0
Comments
In my little brain I always try to think that they are always binary numbers. The conversion to decimal, octal, hex, ASCII etc.. Is just a convenience for us mere mortals to read more easily. keeping that in mind at all times seems to keep me from being confused by the conversions.
No you are not missing something stupid, its not trivial and can get really weird if the hex numbers get larger than an integer or long. If you know how many hex characters there are, and it never changes then there are some strategies you can use. In C there is the strtoul function but Netlinx has no equivalent that I am aware of. This is some open source code for strtoul that you might be able to convert for your usage: