Suppose I have this code
dim a as Integer = 1
dim b, c as Integer
If a And BitwiseAnd(b,c) Then Continue
is the result similar to this code?
If BitwiseAnd(a, BitwiseAnd(b,c)) > 0 Then Continue
Suppose I have this code
dim a as Integer = 1
dim b, c as Integer
If a And BitwiseAnd(b,c) Then Continue
is the result similar to this code?
If BitwiseAnd(a, BitwiseAnd(b,c)) > 0 Then Continue
did you test it? learning is best done by doing
The first code can’t be compiled in Xojo. the second code is not tested yet. I still translate the library into xojo. But, thanks, it’s a good idea.
http://documentation.xojo.com/index.php/Bitwiseand
[code] dim a as Integer = 1
dim b, c as Integer
If a And Bitwise.BitAnd(b,c) Then Continue[/code]
That’s because Xojo will only recognize booleans as conditions in If statements, not values. In other languages, something like if someInt then
will work, but not in Xojo. It must be if someInt <> 0 then
. This is relevant because the and
keyword will double as both a logical comparison and bitwise operator.
In your example, if ( a and ( b and c ) ) <> 0 then
is the easiest way to do what you want.
The Bitwise...
functions, while not deprecated, should be considered legacy and unneeded. It is faster to do a = b and c
than a = BitwiseAnd( b, c )
. The only operations for which they are still needed are ShiftLeft and ShiftRight, unless you want to perform the mathematical equivalents yourself.
Thanks Kem.
I still doubt about mix logical and bitwise operator in Xojo. The actual code is something like this
dim a as Boolean = True
dim b,c as Integer
If a And BitwiseAnd(b, c) Then Exit sub
because this code won’t compile, I think, based on your description, that I will get similar result with this code
If a And (b and c) > 0 Then Exit sub
am I right?
Yes, you need the parenthesis. In your example, if (b and c) > 0
is fine, but if a then
is not, and that’s how the compiler will see it.
Ok, thank you kem.