mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Integer Prototype: get most signifcant bit
Swift SVN r31898
This commit is contained in:
@@ -642,6 +642,15 @@ public func _assumeNonNegative(x: ${Self}) -> ${Self} {
|
||||
% end
|
||||
|
||||
% end
|
||||
|
||||
% fixedBitWidths = [2**x for x in range(3, 8) if 2**x <= 2 * word_bits]
|
||||
% for bits in fixedBitWidths:
|
||||
@transparent
|
||||
public func _leadingZeros(x: Builtin.Int${bits}) -> Builtin.Int${bits} {
|
||||
return Builtin.int_ctlz_Int${bits}(x, true.value)
|
||||
}
|
||||
% end
|
||||
|
||||
//===--- End loop over all integer types ----------------------------------===//
|
||||
|
||||
@available(*, unavailable, renamed="Int")
|
||||
|
||||
Reference in New Issue
Block a user