Poser une questionPoser une question
 

TraitéeC# Logical XOR

Réponses

  • samedi 7 novembre 2009 17:18Tamer OzMVPMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    Hi.

    See this link

    http://msdn.microsoft.com/en-us/library/zkacc7k1.aspx
    it says that

    Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.

    and explanation of example.

    0xf8 is hex and in binary it is 11111000
    0x3f is hex and in binary it is 00111111
    and the result is
    0xc7 is hex and in binary it is 11000111

    Compare the value by bits.

    Ex:

    1 ^ 0 result is 1
    1^1 result is 0

    As you can see if only one of bits is true the result is true otherwise false.

    • Marqué comme réponserecherche samedi 7 novembre 2009 17:35
    •  

Toutes les réponses

  • samedi 7 novembre 2009 17:18Tamer OzMVPMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    Hi.

    See this link

    http://msdn.microsoft.com/en-us/library/zkacc7k1.aspx
    it says that

    Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.

    and explanation of example.

    0xf8 is hex and in binary it is 11111000
    0x3f is hex and in binary it is 00111111
    and the result is
    0xc7 is hex and in binary it is 11000111

    Compare the value by bits.

    Ex:

    1 ^ 0 result is 1
    1^1 result is 0

    As you can see if only one of bits is true the result is true otherwise false.

    • Marqué comme réponserecherche samedi 7 novembre 2009 17:35
    •  
  • samedi 7 novembre 2009 17:35recherche Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Thanks