File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -581,7 +581,7 @@ extension BigInt._Significand {
581
581
return overflow
582
582
}
583
583
584
- // @inlinable
584
+ @inlinable
585
585
internal mutating func multiply( by other: UInt ) {
586
586
var carry = 0 as UInt
587
587
for i in 0 ..< count {
@@ -621,6 +621,10 @@ extension BigInt._Significand {
621
621
}
622
622
623
623
func multiply( _ lhs: Slice < Self > , _ rhs: Slice < Self > ) -> Self {
624
+
625
+ // Based on Karatsuba's method. For details see:
626
+ // <https://mathworld.wolfram.com/KaratsubaMultiplication.html>.
627
+
624
628
let m = ( Swift . max ( lhs. count, rhs. count) + 1 ) / 2
625
629
guard m >= karatsubaThreshold else {
626
630
if lhs. isEmpty || rhs. isEmpty { return Self ( ) }
@@ -648,7 +652,7 @@ extension BigInt._Significand {
648
652
return multiply ( self [ ... ] , other [ ... ] )
649
653
}
650
654
651
- // @inlinable
655
+ @inlinable
652
656
@discardableResult
653
657
internal mutating func divide( by other: UInt ) -> /* remainder: */ Self {
654
658
if other == 1 { return Self ( ) }
@@ -688,8 +692,8 @@ extension BigInt._Significand {
688
692
}
689
693
}
690
694
691
- // Based on Knuth's Algorithm D.
692
- // For details see <https://skanthak.homepage.t-online.de/division.html>.
695
+ // Based on Knuth's Algorithm D (section 4.3.1). For details see:
696
+ // <https://skanthak.homepage.t-online.de/division.html>.
693
697
694
698
// We'll remove any extraneous leading zero words while determining by how
695
699
// much to shift our operands.
You can’t perform that action at this time.
0 commit comments