Skip to main content
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).

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

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.
Tired of Poor C# Skills? Fix That With Deep Grasping!Learn More