Opposite of '|'?
BlitzMax Forums/BlitzMax Programming/Opposite of '|'?
| ||
1|2 is 3. 3|2 is 3. 3?1 is 2. 2?1 is 2. What is "?" |
| ||
with the | (or operator) you are combining bits... with the & (and operator) you are filtering them 3&2 is 2 2*1 is 2 |
| ||
I want to subtract a value from another value if it exists in the value: if (a & b) b=b-a |
| ||
I use this when using bitwise parameters for example, in TileMax I pass an integer flag for drawing the layers Flag:int=Layer1 shl 1+Layer2 shl 2+layer3 shl 3+layer4 shl 4 then to determine if they are set I go DrawLayer1: if flag & %00000001 DrawLayer2: if flag & %00000010 DrawLayer2: if flag & %00000100 DrawLayer2: if flag & %00001000 |
| ||
AND its mask. A & (~B) |
| ||
You have to be working Bitwise for that to work... you just use your powers of 2 so...yes if (a & b) B:-a |
| ||
Strict Local a:Int = $FFFFFF Local b:Int = $00FF00 If a & b Then Print Hex(a)+" contains bits "+Hex(b) a = a&~b Else Print Hex(a)+" does not contain bits "+Hex(b) EndIf If a & b Then Print Hex(a)+" contains bits "+Hex(b) a = a&~b Else Print Hex(a)+" does not contain bits "+Hex(b) EndIf Something like that? If you want to remove bits that are set after you know they're set, ~ (binary not) the flag and then filter them out from the initial value. Also, a&b is not the same as b&a (I think? Now I'm not so sure anymore), so in your example you're.. well, I'm not sure what your example is doing, but hopefully I understood what you were intending to do. |
| ||
That does it:Const FLAG1 = 1 Const FLAG2 = 2 Const FLAG3 = 4 Local flags=1|2|4 Print (FLAG3 & flags) flags=flags &~ FLAG3 Print (FLAG3 & flags) |
| ||
Josh, do me a favor and ask if anyone knows how to start an external app with arguments. You seem to get 10x the responses as me... |
| ||
I would have answered if I had the answer ;) Besides, what are YOU talking about? I cant even get someone to quickly test Tilemax ;) lol |
| ||
That's easy, you just use CreateProcess() and pass the command line arguments in either a second parameter, or after the executable name. I forget which. |