Unexpected Result

cout<<((4000000007*45489)+1749870067);
or
1
2
double i = ((4000000007*45489)+1749870067);
cout<<i;


The result should be 181957750188490 but My computer says 1460693450. WHY
closed account (o1vk4iN6)
You are working with finite data types, you best learn the limitations of them. In the second example you are still doing all the calculations as integers and then simply assigning that result to a double.

 
double i = (4000000007 * 45489.0) + 1749870067;


http://ideone.com/GWjLLK
Oh thanks I just forgot to use .0

Thank
Topic archived. No new replies allowed.