Alex Rivera | Logout

biginteger on Objective-c

Asked 2009-08-04T11:30:22.377
16

Can anyone provide code for a BigInteger implementation in objective-c that provides a PowMod function ?

Edit
Report

2 Answers

4

The closest builtin class in the Cocoa libraries is NSDecimalNumber which provides base-10 arithmetic (and so can handle integer-only arithmetic) for the range mantissa x 10^exponent where mantissa is a 38-bit float and exponent is -128 to 128. If that covers the range you need, there are multiplication and power methods. Otherwise, since Objective-C is a superset of C, any C implementation of bigint that you can find will suffice.

answered 2009-08-04T12:06:10.463
2

I rolled my own wrapper around GMP once, long ago. I've never used any third party BigNum ObjC librariers before, but I had these bookmarked: RSMath, which uses the OpenSSL bignum functions, and MPInteger, which uses GMP.

answered 2009-08-04T20:43:23.317

Your Answer