1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4R Tutorial XOR operation for Boolean

Discussion in 'B4R Tutorials' started by Tayfur, Jul 2, 2019.

  1. Tayfur

    Tayfur Well-Known Member Licensed User

    Do you have more good solitions; Please share it on my article.
    thanks sharings.

    Code:
    '    ----XOR-------
    '    A B Output
    '    -----------
    '    0 0    0
    '    0 1    1
    '    1 0    1
    '    1 1    0
    Public Sub XOR(a As Boolean, b As Boolean) As Boolean
        
    Dim aa,bb As UInt
        
    If a Then aa=1 Else aa=0
        
    If b Then bb=1 Else bb=0
           
        
    Select Bit.Xor(aa,bb)
            
    Case 1
                
    Return True
            
    Case 0
                
    Return False
        
    End Select
        
    Log("ERROR for XOR function")
        
    Return False
    End Sub
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Public Sub XOR(a As Boolean, b As Boolean) As Boolean
      
    Return a <> b
    End Sub
     
    Descartex, Beja, tufanv and 5 others like this.
  3. Tayfur

    Tayfur Well-Known Member Licensed User

    :):):):) why I choose hard way. thannks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice