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

# TypeScript Unsigned Right Shift

The `>>>` (unsigned right shift or zero-fill right shift) operator shifts the binary representation of the first operand to the right by the number of bits specified by the second operand. It discards bits shifted off the right and fills the newly vacated bits on the left with zeroes (`0`). Because it does not preserve the sign bit, the operation always evaluates to a non-negative 32-bit unsigned integer.

```typescript theme={"dark"}
operand1 >>> operand2
```

## Technical Mechanics

1. **Type Coercion:** TypeScript (inheriting from JavaScript's underlying ECMAScript specification) internally converts `operand1` into a 32-bit *unsigned* integer (`ToUint32`).
2. **Shift Masking:** `operand2` is converted to an unsigned 32-bit integer and masked using a bitwise AND (`operand2 & 0x1F`). This restricts the actual shift amount to a value between `0` and `31` bits.
3. **Zero-filling:** As bits are shifted to the right, the leftmost bits are populated with `0`. This fundamentally alters negative numbers, as their leading `1` (the sign bit in two's complement representation) is replaced by `0`.
4. **Return Type:** The result is always returned as a 32-bit unsigned integer, typed as `number` in TypeScript.
5. **BigInt Incompatibility:** `>>>` is the *only* bitwise operator in TypeScript/JavaScript that does not support `BigInt`. Because `BigInt` represents arbitrary-precision integers without a fixed bit-width, an unsigned right shift is mathematically invalid. Attempting to use `>>>` with `bigint` operands throws a compilation error.

## Behavior Visualization

**Positive Integer Shift:**
When shifting positive numbers, `>>>` yields the exact same result as the sign-propagating right shift (`>>`) because the sign bit is already `0`.

```typescript theme={"dark"}
const a: number = 9; 
// 32-bit Binary: 00000000 00000000 00000000 00001001

const result1 = a >>> 2; 
// Shifted Right: 00000000 00000000 00000000 00000010
// result1 === 2
```

**Negative Integer Shift:**
When shifting negative numbers, the 32-bit two's complement representation is shifted. The leading `1`s are replaced with `0`s, resulting in a large positive integer.

```typescript theme={"dark"}
const b: number = -9; 
// 32-bit Binary: 11111111 11111111 11111111 11110111

const result2 = b >>> 2; 
// Shifted Right: 00111111 11111111 11111111 11111101
// result2 === 1073741821
```

**Float Truncation:**
If the left operand is a floating-point number, the fractional portion is truncated during the `ToUint32` coercion before the shift occurs.

```typescript theme={"dark"}
const c: number = 3.99; 
// Truncated to 3
// 32-bit Binary: 00000000 00000000 00000000 00000011

const result3 = c >>> 1; 
// Shifted Right: 00000000 00000000 00000000 00000001
// result3 === 1
```

**Zero-Shift Coercion:**
Shifting by `0` bits forces any value into a 32-bit unsigned integer without altering its bit sequence.

```typescript theme={"dark"}
const d: number = -1;
// 32-bit Binary: 11111111 11111111 11111111 11111111

const result4 = d >>> 0;
// Shifted Right: 11111111 11111111 11111111 11111111 (Interpreted as unsigned)
// result4 === 4294967295
```

**BigInt Rejection:**
Applying `>>>` to `bigint` types results in a strict type error.

```typescript theme={"dark"}
const e: bigint = 9n;

const result5 = e >>> 2n;
// TypeScript Error: Operator '>>>' cannot be applied to types 'bigint' and 'bigint'.
```

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