Is there a type with bigger capacity than u_long or UInt64 in Swift?
I have a function that takes very big integers to identify a credit card numbe
I'm working on a BigNumber library with which you can do some big number calculations. Actually the library is based on the GNU Multiple Precision (GMP) library (see: https://gmplib.org) and I wrote an Objective-C / Swift wrapper. Currently big integer mathematics, including a lot of operator overloading, is possible. A code example goes like:
var err : NSError?
var bi1 = BigInt(nr: 12468642135797531)
var bi2 = BigInt(nr: "12345678901011121314151617181920", error: &err)
var res = bi1 * bi2
println("Multiply 2 BigInts: bi1 * bi2 = \(res.toString())")
which results in:
Multiply 2 BigInts: bi1 * bi2 = 153933852140173822960829726365674325601913839520
You can find the library at: https://github.com/githotto/osxgmp
I think its fairly easy to do some 'credit-card-number' math with even numbers having far more than 28-digits.