> ## 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.

# C# Unsigned Right Shift

The `>>>` operator is the unsigned right shift operator, introduced in C# 11. It shifts the bits of its left-hand operand to the right by the number of positions specified by its right-hand operand, always padding the high-order empty bit positions with zeros.

Unlike the standard right shift operator (`>>`), which performs an *arithmetic* shift on signed integer types (preserving the sign bit by padding with 1s for negative numbers), the `>>>` operator strictly performs a *logical* shift. It ignores the sign bit of the original value and unconditionally shifts zeros into the most significant bit (MSB) positions, regardless of whether the operand's type is signed (`int`, `long`, `sbyte`, `short`) or unsigned (`uint`, `ulong`, `byte`, `ushort`).

```csharp theme={"dark"}
result = expression >>> count;
```

## Mechanical Behavior

**1. Zero Padding**
When shifting a negative signed integer, the `>>>` operator forces a zero into the MSB, effectively changing the sign of the resulting value to positive. For unsigned types, `>>>` and `>>` produce identical results.

```csharp theme={"dark"}
int x = -8; 
// 32-bit binary: 11111111 11111111 11111111 11111000

int arithmeticShift = x >> 2;
// Result: -2
// 32-bit binary: 11111111 11111111 11111111 11111110 (Padded with 1s)

int logicalShift = x >>> 2;
// Result: 1073741822
// 32-bit binary: 00111111 11111111 11111111 11111110 (Padded with 0s)
```

**2. Shift Count Masking**
The actual number of bits shifted is determined by masking the right-hand operand (`count`) to prevent shifting by more bits than the type contains:

* For 32-bit operands (`int`, `uint`), the shift count is evaluated as `count & 0x1F` (equivalent to `count % 32`).
* For 64-bit operands (`long`, `ulong`), the shift count is evaluated as `count & 0x3F` (equivalent to `count % 64`).

**3. Numeric Promotion**
If the left-hand operand is a type smaller than 32 bits (`sbyte`, `byte`, `short`, `ushort`), C# implicitly promotes it to an `int` before performing the shift operation. The result of the `>>>` operation will therefore be an `int`.

```csharp theme={"dark"}
sbyte a = -16;
// Promoted to int: 11111111 11111111 11111111 11110000

var result = a >>> 4; 
// Type is int. Result: 268435455
// Binary: 00001111 11111111 11111111 11111111
```

## Compound Assignment

The operator supports compound assignment via `>>>=`. This evaluates the shift and assigns the result back to the left-hand variable in a single operation.

```csharp theme={"dark"}
int value = -100;
value >>>= 3; 
```

<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 C# 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>
