Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    xor (VB.net 2003)

    I am wondering if anyone can explain the following results in layman terms.

    Dim A As Integer = 10
    Dim B As Integer = 8
    Dim C As Integer = 6
    Dim myCheck As Integer
    myCheck = (A Xor [img]/forums/images/smilies/cool.gif[/img] ' Returns 2.
    myCheck = (A Xor C) ' Returns 12.
    myCheck = (B Xor C) ' Returns 14.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: xor (VB.net 2003)

    In binary,

    A = 1010 (1x8 + 0x4 + 1x2 + 0x1)
    B = 1000
    C = 0110

    Xor contains a 1 where the arguments have 1 and 0 or 0 and 1, and a 0 where the arguments have 0 and 0 or 1 and 1.

    A Xor B = 0010 = 2
    A Xor C = 1100 = 12
    B Xor C = 1110 = 14

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: xor (VB.net 2003)

    Thanks, that make sense now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •