Skip to content

Commit

Permalink
Merge pull request #440 from oguzutku1745/update-operators-shl-wrapped
Browse files Browse the repository at this point in the history
Explanation added to shl_wrapped
  • Loading branch information
d0cd authored Feb 16, 2025
2 parents 33de1d9 + cf1712a commit 1ae7888
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion documentation/leo/04_operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,11 +1069,14 @@ Shifts `first` left by `second` bits, storing the result in `destination`. The o

```leo
let a: u8 = 128u8.shl_wrapped(1u8); // 0u8
let b: i8 = 64i8.shl_wrapped(2u8); // -128i8
```

#### Description

Shifts `first` left by `second` bits, wrapping around at the boundary of the type, storing the result in `destination`.
Shifts `first` left by `second` bits, wrapping around at the boundary of the type, storing the result in `destination`. The shift distance is masked to the bit width of `first`, ensuring that shifting by n is equivalent to shifting by `n % bit_size`.

If bits are shifted beyond the type's range, they are discarded, which may cause sign changes for signed integers.

#### Supported Types

Expand Down

0 comments on commit 1ae7888

Please sign in to comment.