Skip to main content
gamedev.net
๐Ÿ”’ Locked

std::setprecision

Started by Austrian Coder Sep 3, 2003 at 1:21 AM 1 replies 2k views
Original Post
Austrian Coder
Austrian Coder
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
Matsen
Matsen
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.