output - Prevent the zero before the decimal from being displayed in C++ -


in c++, i'm using following statements display output:

// example float x = 0.66004; cout.setf(ios::fixed);   cout.setf(ios::showpoint);   cout.precision(2); cout << x; 

my output looks like

0.66 

how can prevent 0 before decimal being displayed? want:

.66 

std::string foo = std::to_string(0.553); std::size_t = foo.find(".");  if (it != std::string::npos) {     std::cout<<foo.erase(0, it); } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -