| ▲ | dcrazy 3 hours ago | |
Swift: https://developer.apple.com/documentation/swift/binaryintege... > The << operator performs a smart shift, which defines a result for a shift of any value. > - Using a negative value for rhs performs a right shift using abs(rhs). > - Using a value for rhs that is greater than or equal to the bit width of lhs is an overshift, resulting in zero. > - Using any other value for rhs performs a left shift on lhs by that amount. And while the docs don’t say it, `Int.max << 1 == -2`. And in fact, `T.max << 1 == -2` for all `T: BinaryInteger`. | ||