Required Instance Propertyswift 6.0.1Swift
trailingZeroBitCount
The number of trailing zeros in this value’s binary representation.
var trailingZeroBitCount: Int { get }
For example, in a fixed-width integer type with a bitWidth
value of 8, the number -8 has three trailing zeros.
let x = Int8(bitPattern: 0b1111_1000)
// x == -8
// x.trailingZeroBitCount == 3
If the value is zero, then trailingZeroBitCount
is equal to bitWidth
.
Other requirements
Type members
associatedtype Words
A type that represents the words of a binary integer.
init<T>(T
) Creates an integer from the given floating-point value, rounding toward zero.
init<T>(T
) Creates a new instance from the given integer.
init<T>(clamping: T
) Creates a new instance with the representable value that’s closest to the given integer.
init?<T>(exactly: T
) Creates an integer from the given floating-point value, if it can be represented exactly.
init<T>(truncatingIfNeeded: T
) Creates a new instance from the bit pattern of the given instance by sign-extending or truncating to fit this type.
static var isSigned: Bool
A Boolean value indicating whether this type is a signed integer type.
static func % (lhs: Self, rhs: Self
) -> Self Returns the remainder of dividing the first value by the second.
static func %= (lhs: inout Self, rhs: Self
) Divides the first value by the second and stores the remainder in the left-hand-side variable.
static func & (lhs: Self, rhs: Self
) -> Self Returns the result of performing a bitwise AND operation on the two given values.
static func &= (lhs: inout Self, rhs: Self
) Stores the result of performing a bitwise AND operation on the two given values in the left-hand-side variable.
static func * (lhs: Self, rhs: Self
) -> Self Multiplies two values and produces their product.
static func *= (lhs: inout Self, rhs: Self
) Multiplies two values and stores the result in the left-hand-side variable.
static func + (lhs: Self, rhs: Self
) -> Self Adds two values and produces their sum.
static func += (lhs: inout Self, rhs: Self
) Adds two values and stores the result in the left-hand-side variable.
static func - (lhs: Self, rhs: Self
) -> Self Subtracts one value from another and produces their difference.
static func -= (lhs: inout Self, rhs: Self
) Subtracts the second value from the first and stores the difference in the left-hand-side variable.
static func / (lhs: Self, rhs: Self
) -> Self Returns the quotient of dividing the first value by the second.
static func /= (lhs: inout Self, rhs: Self
) Divides the first value by the second and stores the quotient in the left-hand-side variable.
static func << <RHS>(lhs: Self, rhs: RHS
) -> Self Returns the result of shifting a value’s binary representation the specified number of digits to the left.
static func <<= <RHS>(lhs: inout Self, rhs: RHS
) Stores the result of shifting a value’s binary representation the specified number of digits to the left in the left-hand-side variable.
static func >> <RHS>(lhs: Self, rhs: RHS
) -> Self Returns the result of shifting a value’s binary representation the specified number of digits to the right.
static func >>= <RHS>(lhs: inout Self, rhs: RHS
) Stores the result of shifting a value’s binary representation the specified number of digits to the right in the left-hand-side variable.
static func ^ (lhs: Self, rhs: Self
) -> Self Returns the result of performing a bitwise XOR operation on the two given values.
static func ^= (lhs: inout Self, rhs: Self
) Stores the result of performing a bitwise XOR operation on the two given values in the left-hand-side variable.
static func | (lhs: Self, rhs: Self
) -> Self Returns the result of performing a bitwise OR operation on the two given values.
static func |= (lhs: inout Self, rhs: Self
) Stores the result of performing a bitwise OR operation on the two given values in the left-hand-side variable.
static func ~ (x: Self
) -> Self Returns the inverse of the bits set in the argument.
Instance members
var bitWidth: Int
The number of bits in the current binary representation of this value.
var words: Self.Words
A collection containing the words of this value’s binary representation, in order from the least significant to most significant.
func isMultiple(of: Self
) -> Bool Returns
true
if this value is a multiple of the given value, andfalse
otherwise.func quotientAndRemainder(dividingBy: Self
) -> (quotient: Self, remainder: Self) Returns the quotient and remainder of this value divided by the given value.
func signum(
) -> Self Returns
-1
if this value is negative and1
if it’s positive; otherwise,0
.