views:

509

answers:

3

I've been toying around with some Project Euler problems and naturally am running into a lot that require the handling of bigger than long long type numbers. I am committed to using Cocoa and Objective-C (I need to stay sharp for work) but can't find an elegant way (read: library) to handle these really big numbers.

I'd love to use GMP but is sounds like using it with Xcode is a complete world of hurt.

Does anyone know of any other options?

+1  A: 

Try storing the digits in arrays.

Although you will have to write some new functions for all your arithmatic problems but thats how we were told to do it in college.

Plus the speed of calculations was pretty improved as big numbers weren't really big afterall and were not numbers really altogether

see if it helps

regards

OrangeRind
+3  A: 

If I were you I would compile gmp outside XCode and use just gmp.h and libgmp.a (or libgmp.dylib) in my XCode project.

diciu
A: 

If you wanted to use matlab (or anything close) you could look at my implementation of a big integer form (vpi) on the file exchange.

It is rather simple. Store each digit separately. Adds and subtracts are simple, just implement a carry operation. Multiplies are best done using convolution, then a carry. Implement divide and mod operators, then a powermod operation, useful for many of the PE problems. Powers are easy - just repeated squaring and multiplication, based on the binary representation of the exponent.

This will let you solve many PE problems.

woodchips