Problems with double precision
Feb 4, 2012 at 2:56pm
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 Feb 4, 2012 at 2:56pm
Feb 4, 2012 at 3:12pm
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
|
Feb 4, 2012 at 3:15pm
:O
I get it now!
Thanks!
Topic archived. No new replies allowed.