Unknown problem.

Oct 18, 2016 at 1:40pm
Hey!

When I execute the following code..


1
2
3
double test = (17+51*60+37*3600)/3600 // for example..

cout << test << endl;


I get 37.000 printed out instead of 37.854.

Any idea?
Oct 18, 2016 at 1:50pm
If you divide an integer with an integer, the result will be an integer, regardless of the type of variable that you store it in.

If you divide a double by an integer or the other way around, the result will be a double.

Try adding .0 to one of the numbers.
Oct 18, 2016 at 1:59pm
Oh wow really.. I'm so dumb.. Thanks for your reply ^^
Topic archived. No new replies allowed.