what does the ^ symbol mean in c language

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suchithra
    New Member
    • Nov 2015
    • 1

    #1

    what does the ^ symbol mean in c language

    ^ meaning in c language
    ^ symbol meaning of c language
  • mbizup
    New Member
    • Jun 2015
    • 80

    #2
    It's NOT an exponent, like it is in other languages...

    In C, the ^ is "Exclusive OR" (XOR). That means 'either one or the other, but not both'.

    In binary,

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

    Bitwise:

    00 ^ 00 = 00
    00 ^ 01 = 01
    00 ^ 11 = 11
    01 ^ 01 = 00
    01 ^ 00 = 01
    11 ^ 00 = 11
    11 ^ 01 = 10
    etc ...
    Last edited by mbizup; Nov 19 '15, 10:53 AM. Reason: Added examples to show bitwise XORs on more digits.

    Comment

    Working...