Posts RSS Comments RSS 127 Posts and 199 Comments till now

To Hex and Back (The Journey of an Integer)

This is so simple and I forget it every time. This time I am blogging it! (I apologize if the title has been taken before.)

From HEX to Integer
Start Value: 124f80

To convert to Integer we just add 0x and Powershell will do the rest

0×124f80
1200000

From Integer to Hex
Start Value: 1234567

To Convert to HEX we can use the -f operator

"{0:x}" -f 1234567
12d687

UPDATE!

Oisin pointed out these options as well

PS: (4545).tostring("x")
11c1

# or

PS: $n = 4545; $n.tostring("X")
11C1

No Responses to “To Hex and Back (The Journey of an Integer)”

  1. on 21 Feb 2008 at 10:51 amOisin

    also…

    PS# (4545).tostring(\”x\”)
    11c1

    or

    PS# $n = 4545; $n.tostring(\”X\”)
    11C1
    :-)

Trackback this post | Feed on Comments to this post

Leave a Reply

CAPTCHA image