Operator

^(_:_:)

Returns the result of performing a bitwise XOR operation on the two given values.

Declaration

static func ^ (lhs: Int, rhs: Int) -> Int

Parameters

lhs

An integer value.

rhs

Another integer value.

Discussion

A bitwise XOR operation, also known as an exclusive OR operation, results in a value that has each bit set to 1 where one or the other but not both of its arguments had that bit set to 1. For example:

let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x ^ y             // 0b00001011
// z == 11

See Also

Bitwise Operations

static func & (Int, Int) -> Int

Returns the result of performing a bitwise AND operation on the two given values.

static func & (Int, Int) -> Int

Returns the result of performing a bitwise AND operation on the two given values.

static func &= (inout Int, Int)

Stores the result of performing a bitwise AND operation on the two given values in the left-hand-side variable.

static func | (Int, Int) -> Int

Returns the result of performing a bitwise OR operation on the two given values.

static func | (Int, Int) -> Int

Returns the result of performing a bitwise OR operation on the two given values.

static func |= (inout Int, Int)

Stores the result of performing a bitwise OR operation on the two given values in the left-hand-side variable.

static func ^ (Int, Int) -> Int

Returns the result of performing a bitwise XOR operation on the two given values.

static func ^= (inout Int, Int)

Stores the result of performing a bitwise XOR operation on the two given values in the left-hand-side variable.

static func ~ (Int) -> Int

Returns the inverse of the bits set in the argument.