Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =====
- NEW
- =====
- static std::string get_probability_string(const double prob)
- {
- std::ostringstream ss;
- if(prob > 0.9995) {
- ss << "100%";
- } else if(prob >= 0.1) {
- ss << 100.0 * prob << std::setw(4) << std::setprecision(1) << '%';
- } else {
- ss << 100.0 * prob << std::setw(3) << std::setprecision(1) << '%';
- }
- return ss.str();
- }
- =====
- OLD
- =====
- static void format_prob(char str_buf[10], double prob)
- {
- if(prob > 0.9995) {
- snprintf(str_buf, 10, "100 %%");
- } else if(prob >= 0.1) {
- snprintf(str_buf, 10, "%4.1f %%", 100.0 * prob);
- } else {
- snprintf(str_buf, 10, " %3.1f %%", 100.0 * prob);
- }
- str_buf[9] = '\0'; //prevents _snprintf error
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement