Well, basically I was using setprecision(3), but that is rounding up the last number, for example if we do like this –
double x = 5;
x = (double) x / 3;
cout << fixed << setprecision(3) << x << endl;
It will show 1.667
But, if we do it with calculator, it will show – 1.666666666…67
So basically, what I mean is, is there any chance to output in file, just the first 3 digits after the comma, and not to round it up?
we use
int()to truncate the tailing digits.