I don't have a good idea how to do this. I can think of a way to do it really inefficiently, but it won't do. I was thinking that I could load the files into an array, every 4 or so numbers would be a entry, then start at the end of both arrays and add, carrying the needed stuff, which I think would be within my ability to do.

The real problem is that each file has well over 1 billion digits, and loading 1.8 gigabytes into memory really isn't an option on anything but my dev box. Maybe I could load bits of it in at a time, but I don't know how to do this. Start at the end of the file then read backwards 10k digits or something. But again, I don't have a clue how to do this.

What would be a sane way (if any) of doing this?!?

Also, I don't want to use GMP or other maths libraries besides math.h. I'm doing this as a programming exercise.

fake edit: Rereading my post I see that it could come off as asking for help with homework, which I am not. I'm doing this for Physics club at my HS, not for a grade. The larger goal behind all of this is to be able to calculate Pi to an arbitrary digit.

I'm using the formula at http://www.mcs.surrey.ac.uk/Personal/R.Knott/Fibonacci/fibpi.html under the section "Gregory's series and Pi".

I've already written the devision operation (Its where I get the huge text files), but I am having trouble with the addition part