Thread: Tutorial clarification

  1. #1
    Registered User
    Join Date
    Dec 2016
    Posts
    96

    Tutorial clarification

    Good day! I was reading your tutorial, but something is not clear.

    Tutorials - Bitwise Operators and Bit Manipulations in C and C++ - Cprogramming.com

    This does not seems right:

    "You can think of XOR in the following way: you have some bit, either 1 or 0, that we'll call A. When you take A XOR 0, then you always get A back: if A is 1, you get 1, and if A is 0, you get 0. On the other hand, when you take A XOR 1, you flip A. If A is 0, you get 1; if A is 1, you get 0."

    According to the trueth table:

    0 ^ 0 = 0
    0 ^ 1 = 1
    1 ^ 0 = 1
    1 ^ 1 = 0

    So can someone clarify this please?
    Last edited by Salem; 02-21-2017 at 04:04 AM. Reason: Restored original content - the OP edit trashed the meaning and worth of the post

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    The truth table, ordered as per the prose.

    A ^ B =
    1 ^ 0 = 1
    0 ^ 0 = 0
    0 ^ 1 = 1
    1 ^ 1 = 0


    > So can someone clarify this please?
    You didn't say what you thought it should be for us to correct it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2016
    Posts
    96
    I get it now, thank you! At first it seemed a bit unwieldy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-03-2013, 08:50 AM
  2. Clarification....
    By CommonTater in forum C Programming
    Replies: 4
    Last Post: 09-23-2010, 05:39 PM
  3. Help! Need some clarification.
    By jaro in forum C Programming
    Replies: 2
    Last Post: 04-08-2006, 11:44 AM
  4. FAQ Clarification
    By Ness in forum C Programming
    Replies: 13
    Last Post: 06-10-2003, 04:37 PM
  5. A little clarification?
    By Dr Nick in forum C++ Programming
    Replies: 2
    Last Post: 06-20-2002, 01:47 PM

Tags for this Thread