Solved

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

Posted on 2000-04-01
2
165 Views
Last Modified: 2010-04-02
Why does (12 / 4 * 5 / 2) = 7 in C++ ? Does it round? Even if I declare it as a double...

-Dan
0
Comment
Question by:SuperMario
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 10 total points
ID: 2676363
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
 
LVL 3

Author Comment

by:SuperMario
ID: 2676372
Oh... *smacks forehead* Thank you so much for enlightening me!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now