Problems with double precision

This is the code:
1
2
3
4
5
6
#include <iostream>
int main()
{
    double a=999999999; //If I add any more to this variable...
    std::cout<<a;
}

...The compiler sais: integer constant is too large for "long" type

I have read that double can reach 1e+308 not only 1e+009
But yet this is happening. Why?
Last edited on
999999999 is an integer literal so it has the same restrictions as the largest integer type. If you add a dot it will be a double literal.
1
2
99999999999999.
99999999999999.0
:O
I get it now!
Thanks!
Topic archived. No new replies allowed.