Solved

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

Posted on 2000-04-01
2
168 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 128
Grammars for C C++ and java 1 131
How to convert Structure to vector of byte and vice versa 5 24
Outlook 13 41
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

840 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