Advertisement
Vultraz

Untitled

Dec 4th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. static void format_prob(char str_buf[10], double prob)
  2. {
  3.  
  4.     if(prob > 0.9995) {
  5.         snprintf(str_buf, 10, "100 %%");
  6.     } else if(prob >= 0.1) {
  7.         snprintf(str_buf, 10, "%4.1f %%", 100.0 * prob);
  8.     } else {
  9.         snprintf(str_buf, 10, " %3.1f %%", 100.0 * prob);
  10.     }
  11.  
  12.     str_buf[9] = '\0';  //prevents _snprintf error
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement