std::setprecision

Started by
1 comment, last by Austrian Coder 20 years, 7 months ago
Hi! I have a problem with std::setprecision. Lookt at this: std::stringstream stream; stream << std::setprecision(2) << std::fixed << Number[1] << " Euro | " << std::setprecision(Kommastellen) << std::fixed << Number[2] << " Cent | "; Number[1] = 125,4 Number[2] = 12 Now the output is: 125,40 Euro | 12,00 Cent But i need this output: 125,40 Euro | 12 Cent How can i reset the setprescision? Thanks, Christian
Advertisement
Check the value of Kommastellen.
const std::streamsize old = stream.precision(); // save currentstream << std::setprecision(2) << std::fixed << Number[1] << " Euro | " << std::setprecision(0) << std::fixed << Number[2] << " Cent | ";stream.precision(old); // restore 


Regards Mats
great - thanks

This topic is closed to new replies.

Advertisement