Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigInteger equivalent in Swift?

Is there an equivalent to Java's BigInteger class in Swift? I am tying to do large calculations in Swift with positive integers larger than UInt64 maximum valye.

What is the best way to handle these numbers in Swift?

like image 330
liam923 Avatar asked Aug 27 '14 16:08

liam923


1 Answers

You can use the NSDecimalNumber class from Cocoa. It is not infinite precision, but it can represent 38 decimal digits of precision, which may be enough for what you need.

like image 52
newacct Avatar answered Oct 08 '22 11:10

newacct