Double variable not incrementing

Hello all! I just found out about the Collatz Conjecture ( http://en.wikipedia.org/wiki/Collatz_conjecture ), and I noticed that the highest number ever tested for this was around 5.48*10^18. Being a programmer, I decided to see if I could test it farther. This is what I came up with:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
    cout << std::setprecision(1000);
    double dCounter, n;
    ofstream outputfile;
    outputfile.open("Results.txt", ios::trunc);
    outputfile.precision(208);
                        //highest tested number
        for(double i = 547637715000000000; i != 0; i++)
        {
            n = i;
            cout << n << endl;
            dCounter = 0;
            while(n != 1)
            {
                //system("cls");
                dCounter++;
                if(fmod(n, 2) == 1)
                    n = n*3 + 1;
                if(fmod(n, 2) == 0)
                    n /= 2;
                //cout << "Current Value: " << n << endl << "Step: " << dCounter << endl << "Starting Number: " << dStartNumber << endl;
            }
            outputfile << "Number " << i << " resolves to 1" << endl;
        }
    return 0;
}


Now, to me this code looks like it should work. For some reason, the number i will not increase. I have tried multiple ways of doing it, and I can not get it to increase until I bring it down to 5.48*10^16. I have talked to a very knowledgeable friend and even a programming teacher, and neither can figure out what the problem is. According to this ( http://www.informit.com/articles/article.aspx?p=26933 ), the ceiling of the double is 1.8*10^308, well above the value of i. I am running a computer with an i5 and 6 gb of ram, so that is not the problem. Does anybody know why this is not working?
you need a new programming teacher.

double is a floating point representation only going up to about 15 significant figures.

so adding 1 to a number around 10^18 is well below its resolution.
So is there any way for me to work with this number?
You need to use a class of bignums. I don't have much experience of this.

I've heard that GMP is supposed to be good

http://en.wikipedia.org/wiki/GNU_Multi-Precision_Library
Thank you, I will try that.
Topic archived. No new replies allowed.