bitWidth
The number of bits in the current binary representation of this value.
var bitWidth: Int { get }
This property is a constant for instances of fixed-width integer types.
The number of bits in the current binary representation of this value.
var bitWidth: Int { get }
This property is a constant for instances of fixed-width integer types.
import Swift
protocol BinaryInteger : CustomStringConvertible, Hashable, Numeric, Strideable where Self.Magnitude : BinaryInteger, Self.Magnitude == Self.Magnitude.Magnitude
An integer type with a binary representation.
@frozen struct Int
A signed integer value type.
associatedtype Words : RandomAccessCollection where Self.Words.Element == UInt, Self.Words.Index == Int
A type that represents the words of a binary integer.
init<T>(_ source: T) where T : BinaryFloatingPoint
Creates an integer from the given floating-point value, rounding toward zero.
init<T>(_ source: T) where T : BinaryInteger
Creates a new instance from the given integer.
init<T>(clamping source: T) where T : BinaryInteger
Creates a new instance with the representable value that’s closest to the given integer.
init?<T>(exactly source: T) where T : BinaryFloatingPoint
Creates an integer from the given floating-point value, if it can be represented exactly.
init<T>(truncatingIfNeeded source: T) where T : BinaryInteger
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 { get }
A Boolean value indicating whether this type is a signed integer type.
var trailingZeroBitCount: Int { get }
The number of trailing zeros in this value’s binary representation.
var words: Self.Words { get }
A collection containing the words of this value’s binary representation, in order from the least significant to most significant.
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.
override static func * (lhs: Self, rhs: Self) -> Self
Multiplies two values and produces their product.
override static func *= (lhs: inout Self, rhs: Self)
Multiplies two values and stores the result in the left-hand-side variable.
override static func + (lhs: Self, rhs: Self) -> Self
Adds two values and produces their sum.
override static func += (lhs: inout Self, rhs: Self)
Adds two values and stores the result in the left-hand-side variable.
override static func - (lhs: Self, rhs: Self) -> Self
Subtracts one value from another and produces their difference.
override 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 where RHS : BinaryInteger
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) where RHS : BinaryInteger
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 where RHS : BinaryInteger
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) where RHS : BinaryInteger
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.
func isMultiple(of other: Self) -> Bool
Returns true
if this value is a multiple of the given value, and false
otherwise.
func quotientAndRemainder(dividingBy rhs: 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 and 1
if it’s positive; otherwise, 0
.
var bitWidth: Int { get }
The number of bits in the binary representation of this value.