loosing significant figures

I am reading data in from a file and I loose the last digit when I cout.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// read from file  and fill arrays 

	double data[10][3]; // array reads angle, w(angle) errw(angle)
	int x = 0; 
	double  a,b,c,d,e,f;

	while (	dat >> a >> b >> c){

		data[x][0] = a;
		data[x][1] = b;
		data[x][2] = c;

	//	cout << data[x][2] << endl;
		x++;

	}

cout << data[9][1] << "   " <<data[9][2] << endl;

	


1
2
3
4
5
6
7
 
// screen output 

dhilchie@mars  11:39am ->./a.out 
Input filename where the raw data exist-->dat.dat
1.05648   0.077017



the 1.05648 should really read 1.056475 but the 0.07 one is correct
You can change the output precision with, for example, std::cout << std::setprecision(10) (or however many digits you need)
so all my calculations are still keeping those extra digits though?? Its just the cout setting.

if I put the cout << setprecision(10) at the first of my program will it remain for all the rest of the program?
Yes and yes.
Topic archived. No new replies allowed.