Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Austrian Coder

std::setprecision

This topic is 5409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Check the value of Kommastellen.

const std::streamsize old = stream.precision(); // save current

stream << std::setprecision(2) << std::fixed << Number[1] << " Euro | " << std::setprecision(0) << std::fixed << Number[2] << " Cent | ";

stream.precision(old); // restore


Regards Mats

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!