Sign in to follow this  
Followers 0
karliky

Hex conversion

4 posts in this topic

It's possible convert an hex string to numeric representation but with little endian and not big endian byte order?

or may be convert hex string order like "05 60 F8 2D" to " 2D F8 60 05"

sry for my bad english T_T

$string = "717D0500"; Big endian (Motorola byte order)
$string1 = "00057D71"; Litle endian (Intel byter order)
$dec = Dec($string)
MsgBox(1,$dec,$dec)
$dec1 = Dec($string1)
MsgBox(1,$dec1,$dec1)

Share this post


Link to post
Share on other sites



It's possible convert an hex string to numeric representation but with little endian and not big endian byte order?

or may be convert hex string order like "05 60 F8 2D" to " 2D F8 60 05"

sry for my bad english T_T

$string = "717D0500"; Big endian (Motorola byte order)
$string1 = "00057D71"; Litle endian (Intel byter order)
$dec = Dec($string)
MsgBox(1,$dec,$dec)
$dec1 = Dec($string1)
MsgBox(1,$dec1,$dec1)
A very good script to learn about Bit manipulation is at

http://www.autoitscript.com/forum/index.ph...st&p=466668

and the help file to look up at least BitShift and BitOR.

If you enter the four BitShift 's from the code below into Siao's Bitwise operations visualizer, you should be able to work out how I formed the one line conversion in the msgbox. The four BitShift's are joined together with BitOR.

$iN = 0x0560F82D

BitShift(0x0560F82D, -24)
BitShift(BitAND(0x0560F82D, 0x0000ff00), -8)
BitShift(BitAND(0x0560F82D, 0x00ff0000), 8)
BitShift(0x0560F82D, 24)

MsgBox(0, "", Hex(BitOR(BitShift($iN, -24), BitShift(BitAND($iN, 0x0000ff00), -8), BitShift(BitAND($iN, 0x00ff0000), 8), BitShift($iN, 24))))

Share this post


Link to post
Share on other sites
OMG TNX!!!

Share this post


Link to post
Share on other sites

or may be convert hex string order like "05 60 F8 2D" to " 2D F8 60 05"

I looked at your question again and had a go at the format you specified as an exercise.

$string = "05 60 F8 2D"
$iN = "0x" & StringStripWS($string, 8) ; = 0x0560F82D

BitAND(0x0560F82D, 0x000000ff)
BitShift(BitAND(0x0560F82D, 0x0000ff00), 8)
BitShift(BitAND(0x0560F82D, 0x00ff0000), 16)
BitShift(0x0560F82D, 24)

MsgBox(0, "", Hex(BitAND($iN, 0x000000ff), 2) & " " & Hex(BitShift(BitAND($iN, 0x0000ff00), 8), 2) & _
        " " & Hex(BitShift(BitAND($iN, 0x00ff0000), 16), 2) & " " & Hex(BitShift($iN, 24), 2))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0