# BitAnd with unsigned 32 bit integers

## Recommended Posts

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 on other sites

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

##### Share on other sites

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 on other sites

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 on other sites

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

## Create an account

Register a new account