Its not clear what you want to do. Can you say in words what you want to achieve and why you want to use a double instead of a long to do it. Why are you using %
Using a floating-point variable as a counter is fraught with problems. Just because it can store numbers larger than an integer variable doesn't mean it can store every number larger than an integer variable.
Sure, it starts out sweet:
1
2
3
:
300
301
:
3000
3001
:
But at some point, you'll find it's not counting anymore. It will just get stuck. Why?
A floating-point number is really two numbers in one. It's a mantissa, and an exponent. Sorta like the number 3.2*106 is equivalent to writing 3200000. The "3.2" part is the mantissa, and the "6" part is the exponent.
However, on the computer, both the mantissa and the exponent need to fit in the same limited number of bits in the variable. It's a tradeoff. If you have a lot of mantissa digits, you can't store many exponent digits. If you have a lot of exponent digits, you can't store many mantissa digits. Our example of 3.2 and 6 is three digits to write the mantissa and exponent. If you wanted to add one to 3.2106, you'd have to write 3.200001106, a total of eight digits. If the variable can only fit six digits, then that ends up looking like 3.2000*106, which is the same thing you had before you added one!
Great info Guys!
Now that I know what the problem is I have a plan
I will use a pair of type int variables. Since my count will always be an integer and always positive I can use the second variable as a roll over counter.
//pick a nice number, call it 50000
if ( varA == 50000) { varB += 1; varA = 0; }
// sorta like an old time speedometer!
now go count some more!
(message to self: don't forget the logic to cound forward and backward :-?)