File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,17 @@ public struct Alignment: Comparable, Hashable {
2727 ///
2828 /// An n-byte alignment contains log-base-two-many least-significant zeros.
2929 public func log2( ) -> UInt32 {
30+ guard !isZero else { return 0 }
3031 return 31 - UInt32( self . rawValue. leadingZeroBitCount)
3132 }
3233
3334 /// Returns the log-base-two value of this alignment as a 64-bit integer.
3435 ///
3536 /// An n-byte alignment contains log-base-two-many least-significant zeros.
3637 public func log2( ) -> UInt64 {
37- return 63 - UInt64( self . rawValue. leadingZeroBitCount)
38+ guard !isZero else { return 0 }
39+ // rawValue is only 32 bits
40+ return 31 - UInt64( self . rawValue. leadingZeroBitCount)
3841 }
3942
4043 /// Returns the alignment of a pointer which points to the given number of
You can’t perform that action at this time.
0 commit comments