Jump to content
Sign in to follow this  
fspafford

BitAnd with unsigned 32 bit integers

Recommended Posts

fspafford

I am having problems with the Bit*** functions because they work with signed integers and I need to work with unsigned integers. Is there a recommended workaround for this problem?


Frank

Share this post


Link to post
Share on other sites
weaponx

Can you give me an example of expected versus actual result?

Share this post


Link to post
Share on other sites
TerarinK

Because a signed value to a integer run from -2,147,483,648 to 2,147,483,647 in a 32 bit system and unsigned value run from 0 to 4,294,967,295 in a 32 bit system. There a multiple way to add on to bit, I would search "Inifinite Bits" in a search engine to get your information as it would be just as easy to inplement them in here


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites
PsaltyDS

I am having problems with the Bit*** functions because they work with signed integers and I need to work with unsigned integers. Is there a recommended workaround for this problem?

"Signed" and "unsigned" do not mean anything to the Bit* functions. It only changes the way they are displayed in decimal. As long as you are doing either bit operations with Bit* (or maybe some Binary*) functions, and not mixing that with math or String* operations, you will be fine:
$binVar = 0x7FFFFFFF
ConsoleWrite("$binVar = " & $binVar & @LF)
ConsoleWrite("Hex = " & "0x" & Hex($binVar, 8) & @LF)
$binVar = BitOR(0x80000000, $binVar)
ConsoleWrite("$binVar = " & $binVar & @LF)
ConsoleWrite("Hex = " & "0x" & Hex($binVar, 8) & @LF)
$binVar = BitAND(0xF0F0F0F0, $binVar)
ConsoleWrite("$binVar = " & $binVar & @LF)
ConsoleWrite("Hex = " & "0x" & Hex($binVar, 8) & @LF)
$binVar = BitXOR(0xFFFFFFFF, $binVar)
ConsoleWrite("$binVar = " & $binVar & @LF)
ConsoleWrite("Hex = " & "0x" & Hex($binVar, 8) & @LF)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Richard Robertson

Is the problem perhaps that AutoIt uses an internal 64 bit integer? Most people try to operate on the 32 bit boundary and only expect it to run those 32.

Edited by Richard Robertson

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.