biginteger on Objective-c

I hope it’s not too late to answer this thread. You can try “LibTomMath” which is opensource and free (the author give away this project as public domain). It works out of the box without any configuration, just put all bn_*.c and tommath*.h to your Xcode project and you are ready to go. #import “tommath.h” … Read more

How do I do big integers in Fortran?

There is no built-in “big number” support, but we can first check whether there is a larger integer kind available (as mentioned by Francescalus above and also many previous pages (e.g. this page). On my computer with gfortran-6.1, the compiler seems to support 128-bit integer kind, so I could calculate the result up to n=160 … Read more

Often big numbers become negative

This image shows what you’re looking for. In your case it’s obviously larger numbers, but the principle stays the same. Examples of limits in java are: int: −2,147,483,648 to 2,147,483,647. long: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 In the image 0000, 0001 etc, shows the binary representation of the numbers. EDIT: In project euler you often have to … Read more

BigInteger.pow(BigInteger)?

You can write your own, using repeated squaring: BigInteger pow(BigInteger base, BigInteger exponent) { BigInteger result = BigInteger.ONE; while (exponent.signum() > 0) { if (exponent.testBit(0)) result = result.multiply(base); base = base.multiply(base); exponent = exponent.shiftRight(1); } return result; } might not work for negative bases or exponents.