So how do you print a double?

OK, I need to print a really BIG number sometimes. geeWiz is a counter in my program and it counts ALOT!

This little bit of code :

volatile double geeWiz = 0;

void setup() {

Serial.begin (9600);
Serial.println("Lets GO!");

}

void loop(){
if(geeWiz % (double)1000 == (double)0){
Serial.println (geeWiz, DEC);
}
}

gets me:
In function 'void loop()':
error: invalid operands of types 'volatile double' and 'double' to binary 'operator%'

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 %

The modulus operator '%' only works with integers, whereas your code tries to use it on a 'double'.

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 :wink:
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 :-?)

Why not just use a long integer?

that has a range of [ch8722]2,147,483,648 to 2,147,483,647

Oh, well, meeby cuz i "ASSUMED" I would have the same trouble there and we all know what happens when you "ASSUME" :-[