Skip to content

Commit 1ae7888

Browse files
authored
Merge pull request #440 from oguzutku1745/update-operators-shl-wrapped
Explanation added to shl_wrapped
2 parents 33de1d9 + cf1712a commit 1ae7888

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

documentation/leo/04_operators.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,11 +1069,14 @@ Shifts `first` left by `second` bits, storing the result in `destination`. The o
10691069

10701070
```leo
10711071
let a: u8 = 128u8.shl_wrapped(1u8); // 0u8
1072+
let b: i8 = 64i8.shl_wrapped(2u8); // -128i8
10721073
```
10731074

10741075
#### Description
10751076

1076-
Shifts `first` left by `second` bits, wrapping around at the boundary of the type, storing the result in `destination`.
1077+
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`.
1078+
1079+
If bits are shifted beyond the type's range, they are discarded, which may cause sign changes for signed integers.
10771080

10781081
#### Supported Types
10791082

0 commit comments

Comments
 (0)