Saturday, July 11, 2009

Week 5

What an eventful week! Week contained within "containers," and week's tasks iterated over debugging "iterators" :) I spent most of this week working on the project 4 - Integer. And wow, I must say, I learned a lot. The pair programming paid off again. Having worked with the partner simultaneously on the project, allowed me to learn a lot many new concepts of C++; and most importantly their applications and usage.

The project 4 served as a good recall of elementary arithmetic operations: addition, subtraction, multiplication, and division. The project revolves around arbitrary precision integer operations; and the fun part was to calculate the 30th Mersenne prime number (2^132049 - 1) which is around 40000 digits long. And we had it calculated in less than 20 seconds on a Intel Core 2 Duo 2.2 GHz Processor. The optimization technique was to divide the exponent into some power of 2, and multiply them together to find the original power.

There was a doubt though running through me: what's the modulus x % y, when x is a negative number. For instance, -3 % 5 = ? Should it be 2, or -3. While C++ itself calculates it to be -3, while my understanding (as well as Google's) is it should be a positive number. Oh well, we went with the C++ understanding :)

No comments:

Post a Comment