• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

(12 / 4 * 5 / 2) = 7 ??

Why does (12 / 4 * 5 / 2) = 7 in C++ ? Does it round? Even if I declare it as a double...

-Dan
0
SuperMario
Asked:
SuperMario
1 Solution
 
jkrCommented:
This is because you're using plain integer constants...

Try

(12.0 / 4.0 * 5.0 / 2.0)

and you should receive the expected result.
0
 
SuperMarioAuthor Commented:
Oh... *smacks forehead* Thank you so much for enlightening me!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now