> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go Bitwise XOR

In Go, the `^` symbol functions as a bitwise operator exclusively for integer types. Its behavior is determined by its arity: it acts as a **bitwise XOR (Exclusive OR)** when used as a binary operator, and as a **bitwise NOT (Complement)** when used as a unary operator.

## Binary Operation: Bitwise XOR

When placed between two operands, `^` performs a logical exclusive OR operation on each corresponding pair of bits. It yields `1` if the bits are different, and `0` if they are identical.

```go theme={"dark"}
var a uint8 = 12 // Binary: 00001100
var b uint8 = 10 // Binary: 00001010

result := a ^ b  // Binary: 00000110 (Decimal: 6)
```

## Unary Operation: Bitwise NOT (Complement)

When placed before a single operand, `^` acts as the bitwise complement operator. Go uses `^` for this operation instead of the `~` operator found in C-family languages. It inverts every bit of the operand, changing `0` to `1` and `1` to `0`.

```go theme={"dark"}
var a uint8 = 12 // Binary: 00001100

result := ^a     // Binary: 11110011 (Decimal: 243)
```

**Behavior with Signed Integers:**
Because Go represents signed integers using two's complement architecture, applying the unary `^` to a signed integer inverts the sign bit alongside the data bits. Mathematically, `^x` on a signed integer evaluates to `-(x + 1)`.

```go theme={"dark"}
var x int8 = 12  // Binary: 00001100

result := ^x     // Binary: 11110011 (Decimal: -13)
```

## Composite Operator: Bit Clear (`&^`)

The `^` character is also a constituent of Go's bit clear (AND NOT) operator, `&^`. This binary operator clears the bits of the left operand wherever the corresponding bits of the right operand are `1`. It is mechanically equivalent to `a & (^b)`.

```go theme={"dark"}
var a uint8 = 12 // Binary: 00001100
var b uint8 = 10 // Binary: 00001010

result := a &^ b // Binary: 00000100 (Decimal: 4)
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Go Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
