<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Int/&__=(_:_:)-2i06i",
  "metadataVersion" : "0.1.0",
  "role" : "Operator",
  "symbol" : {
    "kind" : "Operator",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Si4aggeoiyySiz_SitFZ"
  },
  "title" : "&>>=(_:_:)"
}
-->

# &>>=(_:_:)

Calculates the result of shifting a value’s binary representation the
specified number of digits to the right, masking the shift amount to the
type’s bit width, and stores the result in the left-hand-side variable.

```
static func &>>= (lhs: inout Int, rhs: Int)
```

## Parameters

`lhs`

The value to shift.

`rhs`

The number of bits to shift `lhs` to the right. If `rhs` is
outside the range `0..<lhs.bitWidth`, it is masked to produce a
value within that range.

## Discussion

The `&>>=` operator performs a *masking shift*, where the value passed as
`rhs` is masked to produce a value in the range `0..<lhs.bitWidth`. The
shift is performed using this masked value.

The following example defines `x` as an instance of `UInt8`, an 8-bit,
unsigned integer type. If you use `2` as the right-hand-side value in an
operation on `x`, the shift amount requires no masking.

```
var x: UInt8 = 30                 // 0b00011110
x &>>= 2
// x == 7                         // 0b00000111
```

However, if you use `19` as `rhs`, the operation first bitmasks `rhs` to
`3`, and then uses that masked value as the number of bits to shift `lhs`.

```
var y: UInt8 = 30                 // 0b00011110
y &>>= 19
// y == 3                         // 0b00000011
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)