Jump to content

Recommended Posts

Posted

Somebody please explain to me ,when I try Bitshift with the same input in python and autoit. They have given different results
python

print(1600707826 << 24)

autoit

BitShift(1600707826,-24)

tested on win 7 64

Posted (edited)

The most likely reason in this case is because, in AutoIt, bit operations are performed as 32-bit integers.  Your result will definitely be outside the range of a 32-bit integer.

The highlighted information was taken from the BitShift function entry in the AutoIt Help File.

 

This should illustrate the issue.

Const $INT = 1600707826
ConsoleWrite(StringFormat("Value in hex       = %X (%i)", $INT, $INT) & @CRLF)
ConsoleWrite(StringFormat("Value << 24 in hex = %X (%i)", BitShift($INT, -24), BitShift($INT, -24)) & @CRLF)

Output

Value in hex       = 5F68DCF2 (1600707826)
Value << 24 in hex = F2000000 (-234881024)

 

Of course the correct answer is: 005F 68DC F200 0000 (26,855,420,949,692,416)

 

If you want to do 64-bit bit operations, you may want to check out the topic below...

 

Edited by TheXman

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...