Using setprecision

This is the final line of my code.

1
2
cout<<"Resultant Force vector in Newtons and Cartesian form: "<<fixed<<setprecision(.1)<<pointSum[0]<<"i "<<pointSum[1]<<"j "<<pointSum[2]<<"k"<<endl;
    return 0;


I set the precision to .1.

And for example it displays:
Resultant Force vector in Newtons and Cartesian form: +322i -17j -1467k

I wanted my code to only display first three significant figures. Would I still need to use setprecision or something else?
See http://cplusplus.com/reference/iostream/manipulators/setprecision/
Firstly, it takes an integer. 0.1 is truncated to 0. Secondly, if you set fixed, it shows n digits after dot, if you don't it shows n digits total.
Topic archived. No new replies allowed.