Android Question Boolean XOR ("exclusive or" bit operator)

js1234

Member
Licensed User
What is XOR boolean operator?
Like "And" "Or" …. why using "Xor" get syntax error?

BR
 

js1234

Member
Licensed User
Xor output is true if only one of the inputs are true

1 xor 0 = 1
0 xor 1 = 1
0 xor 0 = 0
1 xor 1 = 0

Yes Yes I know ….. but:

B4X:
 Dim bTest1 As Boolean
 Dim bTest2 As Boolean

 If bTest1 And bTest2 Then
 
 End If


working OK but this is SYNTAX ERROR:

B4X:
 If bTest1 Xor bTest2 Then
 
 End If

Why?
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Yes Yes I know ….. but:

B4X:
 Dim bTest1 As Boolean
 Dim bTest2 As Boolean

 If bTest1 And bTest2 Then
 
 End If


working OK but this is SYNTAX ERROR:

B4X:
 If bTest1 Xor bTest2 Then
 
 End If

Why?
B4X:
    Dim b1 As Int = 1
    Dim b2 As Int = 1
    Dim b3 As Int
    
    b3 = Bit.Xor(b1,b2)
    Log(b3)
 
Upvote 0
Top