FixedWidthInteger
extension FixedWidthInteger
-
Divide the double-width integer
dividendbyselfand return the quotient and remainder.Requires
dividend.high < self, so that the result will fit in a single digit.Complexity
O(1) with 2 divisions, 6 multiplications and ~12 or so additions/subtractions.Declaration
Swift
internal func fastDividingFullWidth(_ dividend: (high: Self, low: Self.Magnitude)) -> (quotient: Self, remainder: Self) -
Return the quotient of the 3/2-word division
x/yas a single word.Requires
(x.0, x.1) <= y && y.0.high != 0Declaration
Swift
static func approximateQuotient(dividing x: (Self, Self, Self), by y: (Self, Self)) -> SelfReturn Value
The exact value when it fits in a single word, otherwise
Self.
FixedWidthInteger Extension Reference