Required Instance Methodswift 6.0.1Swift
dividedReportingOverflow(by:)
Returns the quotient obtained by dividing this value by the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func dividedReportingOverflow(by rhs: Self) -> (partialValue: Self, overflow: Bool)
Parameters
- rhs
The value to divide this value by.
Returns
A tuple containing the result of the division along with a Boolean value indicating whether overflow occurred. If the overflow
component is false
, the partialValue
component contains the entire quotient. If the overflow
component is true
, an overflow occurred and the partialValue
component contains either the truncated quotient or, if the quotient is undefined, the dividend.
Dividing by zero is not an error when using this method. For a value x
, the result of x.dividedReportingOverflow(by: 0)
is (x, true)
.
Other requirements
Type members
init(bigEndian: Self
) Creates an integer from its big-endian representation, changing the byte order if necessary.
init(littleEndian: Self
) Creates an integer from its little-endian representation, changing the byte order if necessary.
static var bitWidth: Int
The number of bits used for the underlying binary representation of values of this type.
static var max: Self
The maximum representable integer in this type.
static var min: Self
The minimum representable integer in this type.
static func &* (lhs: Self, rhs: Self
) -> Self Returns the product of the two given values, wrapping the result in case of any overflow.
static func &<< (lhs: Self, rhs: Self
) -> Self Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width.
static func &<<= (lhs: inout Self, rhs: Self
) Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
static func &>> (lhs: Self, rhs: Self
) -> Self Returns the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width.
static func &>>= (lhs: inout Self, rhs: Self
) Calculates the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
Instance members
var bigEndian: Self
The big-endian representation of this integer.
var byteSwapped: Self
A representation of this integer with the byte order swapped.
var leadingZeroBitCount: Int
The number of leading zeros in this value’s binary representation.
var littleEndian: Self
The little-endian representation of this integer.
var nonzeroBitCount: Int
The number of bits equal to 1 in this value’s binary representation.
func addingReportingOverflow(Self
) -> (partialValue: Self, overflow: Bool) Returns the sum of this value and the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func dividingFullWidth((high: Self, low: Self.Magnitude)
) -> (quotient: Self, remainder: Self) Returns a tuple containing the quotient and remainder obtained by dividing the given value by this value.
func multipliedFullWidth(by: Self
) -> (high: Self, low: Self.Magnitude) Returns a tuple containing the high and low parts of the result of multiplying this value by the given value.
func multipliedReportingOverflow(by: Self
) -> (partialValue: Self, overflow: Bool) Returns the product of this value and the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func remainderReportingOverflow(dividingBy: Self
) -> (partialValue: Self, overflow: Bool) Returns the remainder after dividing this value by the given value, along with a Boolean value indicating whether overflow occurred during division.
func subtractingReportingOverflow(Self
) -> (partialValue: Self, overflow: Bool) Returns the difference obtained by subtracting the given value from this value, along with a Boolean value indicating whether overflow occurred in the operation.