Hex String to Integer

Hi all,

Definite newbie here so bear with me. :slight_smile:

I have a script that pulls a hex string from a file in the format A5B7. It will always only be four digits. I need to have that hex string converted into a numeric value such as an Int16 or something similar. I’m usually good at Google but I can’t seem to find what I need.

Thanks!
-Dave

You will need to first make it a legitimate hexadecimal number by prefixing “0x” to the number. Now cast it to an integer, in Powershell cast look like this [type]

[int] 0xA5B7

42423

Bob,

My thanks for an amazingly simple solution. I had it right except that I didn’t put on the prefix “0x” to make the hex string a hex number. I didn’t even need to convert it - I just put on the prefix and assigned it which made the variable a number.

Many thanks!
-Dave