Skip to content

Instantly share code, notes, and snippets.

@BeauNouvelle
Last active April 4, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeauNouvelle/38cb5b91553ed4618219367c4cea8cfb to your computer and use it in GitHub Desktop.
Save BeauNouvelle/38cb5b91553ed4618219367c4cea8cfb to your computer and use it in GitHub Desktop.
More changes to BigInt
func multiply(right: BigInt) -> BigInt {
var a1 = value.characters.reversed().map { Int(String($0))! }
var a2 = right.value.characters.reversed().map { Int(String($0))! }
...
...
// And change the last line
return BigInt(value: result.map { String($0) }.joined(separator: ""))
}
// Our calculation now looks like this.
let int1 = BigInt(value: "34")
let int2 = BigInt(value: "45")
let product = int1.multiply(int2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment