setprecision() may help. Consider to include <iomanip>.