double lacking precision

closed account (jLNv0pDG)
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

int main()
{
	double x = 123.456789;

	std::cout << x;

	return 0;
}
123.457


Double is supposed to give me 15 decimal digits precision. Can anyone explain why I am only getting 6? Is cout somehow to blame? :\
Last edited on
Notice that due to floating point arithmetic imprecision, if you show too many digits you'll get the output to be slightly different from the value of the literal you have in the sourcecode
Topic archived. No new replies allowed.