The operation I want is the inverse of doubleWidthMultiply, where you have a (high, low) word pair and you want to divide it by a single word, getting a quotient and remainder. This is an important building block for implementing arbitrary precision division. Intel’s DIV can do this in a single instruction, while doing it in code requires a lot of work:
https://github.com/lorentey/BigInt/blob/swift3/Sources/BigDigit.swift#L119-L176 > On 2016-06-24, at 20:52, Haravikk <[email protected]> wrote: > > >> On 24 Jun 2016, at 18:17, Károly Lőrentey via swift-evolution >> <[email protected]> wrote: >> I’m especially stoked about `FixedWidthInteger.doubleWidthMultiply`, which >> will likely lead to a measurable speedup. Why is there no >> `doubleWidthQuotientAndRemainder` or `doubleWidthDivide`, though? > > Double-width isn't needed for these as it's impossible for an integer to > become larger when dividing (the smallest value you can divide by and get a > result is 2, which will halve the value), and the remainder can't be larger > than the original value. > > > Anyway, I'm hugely in favour of this proposal, it's desperately needed! _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
