Advertisement
Vultraz

Untitled

Dec 4th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. static std::string get_probability_string(const double prob)
  2. {
  3.     std::ostringstream ss;
  4.  
  5.     if(prob > 0.9995) {
  6.         ss << "100%";
  7.     } else if(prob >= 0.1) {
  8.         ss << std::setw(4) << std::setprecision(1) << 100.0 * prob << '%';
  9.     } else {
  10.         ss << std::setw(3) << std::setprecision(1) << 100.0 * prob << '%';
  11.     }
  12.  
  13.     return ss.str();
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement