Jump to content
Sign in to follow this  
VeeDub

Working with 32 bit numbers

Recommended Posts

VeeDub

Hi,

I am trying to perform some bit operations on 32 bit addresses, but I cannot get it to work. The issue I think is that the BitXOR function requires values rather than strings.

If I try to supply a 32 bit number as a value directly:

$x = BitXOR(4c250e81,9be548aa)

Then I get a syntax error. But if I provide the values as strings, then I get a nonsense answer. At the moment the only way I can see to get around this is to convert the hexadecimal values to their integer equivalent - and then convert it back afterwards. Which I can do, but I wonder if I'm missing something really simple here.

Thanks

VW

Share this post


Link to post
Share on other sites
VeeDub

add '0x'

Thanks for that, I'm glad I asked.

Cheers,

VW

Share this post


Link to post
Share on other sites
VeeDub

Sorry, I haven't got this quite worked out, another question.

I don't understand why the following two examples produce different results:

$x = BitXOR(0x4c250e81,0x9be548aa)
MsgBox(0,"X",$x)

$X = -675264981

$z = "9be548aa"
$y = BinaryString($z)
$x = bitxor(0x4c250e81,$y)
MsgBox(0,"X",$x)

$X = 1277497016

Thanks

VW

Share this post


Link to post
Share on other sites
VeeDub

OK, I have figured this out, for the second example to work it needs to be as follows:

$z = "9be548aa"
$y = Dec($z)
$x = bitxor(0x4c250e81,$y)
MsgBox(0,"X",$x)

$X = -675264981

Basically the binarystring function doesn't work the way that I expected it too. This thread explains more.

Cheers

VW

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.