XOR using mathematical operators

前端 未结 9 1598
北海茫月
北海茫月 2021-02-05 09:57

How can I implement XOR using basic mathematical operators like +,-,*,/

Update: Actually, I need to track change in two matrix having Boolean values. T

9条回答
  •  走了就别回头了
    2021-02-05 10:01

    In Brown, G. and Dell, R., Formulating linear and integer linear programs: A rogues’ gallery the following linear programming formulation for the XOR can be found:

    Z3 = Z1 XOR Z2
    

    resolves to

    Z3 <= Z1 + Z2
    Z3 >= Z1 - Z2
    Z3 >= -Z1 + Z2
    Z3 <= 2 - Z1 - Z2
    

提交回复
热议问题