Converting Hex Numbers

by Jun 15, 2020

PowerShell can interactively convert hexadecimal numbers when you prefix “0x”:

 
PS> 0xAB0f
43791 
 

If the hex number is stored in a string, you can invoke the conversion by applying a type to the expression:

 
PS> $a = 'ab0f'

PS> [int]"0x$a"
43791 
 


Twitter This Tip! ReTweet this Tip!