0

In a program that I am making, I require rather large numbers, for instance 1000000000000000000 also known as a quintillion. This number is just within the regions of the largest possible Int() in swift. Lets say I wanted to store 10 quintillion (10 x 10^19) into a variable. What would be the best way to approach this problem, if there is a solution at all...

In addition to this I would need to find a way to store this in UserDefaults.

RhysD
  • 1,597
  • 2
  • 17
  • 30
  • 1
    Possible duplicate of [BigInteger equivalent in Swift?](http://stackoverflow.com/questions/25531914/biginteger-equivalent-in-swift). – Martin R Feb 26 '17 at 18:26
  • @MartinR I edited it to say why it is different – RhysD Feb 26 '17 at 18:28
  • Look into `Decimal`/`NSDecimalNumber`. – rmaddy Feb 26 '17 at 18:30
  • Using NSDecimalNumber is one of the answers given in the linked-to Q&A – Martin R Feb 26 '17 at 18:32
  • @MartinR But that doesn't make it a duplicate question. This question has nothing to do with Java's `BigInteger`. – rmaddy Feb 26 '17 at 18:34
  • I would consider is a duplicate of *"I am tying to do large calculations in Swift with positive integers larger than UInt64's maximum number. What is the best way to handle these numbers?"* – Martin R Feb 26 '17 at 18:36
  • @MartinR but my question requires it to be functional with NSUserDefaults, which that question doesn't help at all with. – RhysD Feb 26 '17 at 18:37

0 Answers0