Doubles

Is there any way to prevent doubles from rounding? I'm preforming operations like multiplying and dividing but it rounds the double. Is there a way to prevent this or is it DevC++ being dumb?
What do you mean? If you output the result of an integer, the result would obviously get casted. Without you telling us what exactly you do, it's hard to tell what your problem is. Oh and:
http://www.jasonbadams.net/20081218/why-you-shouldnt-use-dev-c/
Alright so I have a program that is doing calculations based on what the user types in. So it the user types 23.42 and then * and then 1234.412, it would give them 28909.9 when my calculator gives me 28909.92904. Why is that?
Last edited on
1
2
3
4
5
6
7
8
9
10
#include <iomanip>
#include <iostream>

int main()
{
  double d = 23.42 * 1234.412;
  // the rounding is from cout. double's are always precise, cout rounds. You need these from the iomanip header.
  std::cout << std::fixed << std::setprecision(5) << std::showpoint << d << std::endl;
  return 0;
}
Just making sure, if I use: using namespace std; I don't have to type the "std::" right?
That is correct.
Alright thanks!
Topic archived. No new replies allowed.