Search code examples
javaimplication

how to code implication/equivalence in java


Hello i am a beginner in coding the logic with java , So i wanted to know how can i code the following information. i have these variables in a file presented like following

example: my file.txt

5 1 4 
6 2 3

the numbers actually represent something like:

@1: hair = false
@2: hair = true
@3: feathers = false
@4: feathers = true

what i need to do, is to code

{non 5 ⟺ 2 ∨ 3 } ∧{non 6 ⟺ 1 ∨ 4 }

in java

Now, i know that normally i should transform the ⟺ (implication/implies)to an ∨(or) but i don't how to proceed

Thanks for you help


Solution

  • I think you are looking for these bitwise functions:

    ⟺ = xnor = !(a ^ b)
    ∨ = or = a | b
    ∧ = and = a & b

    boolean result = ((!(5 ^ 2)) | 3) & ((!(6 ^ 1)) | 4)
    

    If by non you mean not, then just add a ! where you need a negation.